Quantcast
Channel: NAudio
Viewing all 5831 articles
Browse latest View live

New Post: how to play gsm and dss files using NAudio

$
0
0
Hi markheath,

Can u give me a sample for how to add codec in naudio. because I m having the codec for dss file.

Thanks in advance.

New Post: VB.NET - Buffer full TCP-Server

$
0
0
This code is from NAudio Network Chat, only in VB.NET and as TCP.
Therefore i asked.

New Post: VB.NET - Buffer full TCP-Server

$
0
0
well for the buffer to fill up you are receiving audio faster than you are playing it, which is odd.
So main ways you can fix that are
  1. increase the buffer size, maybe it's just a transient issue
  2. throw away received audio when the buffer is looking full

New Post: DataChunk header in wrong position

$
0
0
I am quite new at using naudio and I am following an example provided I found on this site to trim wav files. I am using the example along with my own code to determine the lengths of wave files and trimming them to be at a length that I can use.

The program works great, it trims them perfectly everytime, exactly how I need them except for the datachunk. It is always 2 positions forward. Looking at my wav file in HxD, my original wav file datachunk is in position 37-40.

After I trim the file the datachunk is in position 39-42. This causes a problem in the other program I an using to look at the files. I have tried opening in Audacity and exporting and the datachunk position gets corrected, not sure why but it does. I have also altered the position in HxD and that works too but I would rather not have to go through all of the extra steps if I do not have to.
As I am new to naudio I am unsure if I am doing something wrong (Very possible) and I have looked for similar problems for a few days now and cannot find a single solution.

Here is the code I found through this site. The rest of my code just determines the amount that I need to trim based on the lot of files I am altering. I just read a wave file, trim and store in a different folder.

any help would be greatly appreciated, if you need any more information please let me know and I will provide what I am able to.
 public static void TrimWavFile(string inPath, string outPath, TimeSpan cutFromStart, TimeSpan cutFromEnd)
        {
            using (WaveFileReader reader = new WaveFileReader(inPath))
            {
                using (WaveFileWriter writer = new WaveFileWriter(outPath, reader.WaveFormat))
                {
                    int bytesPerMillisecond = reader.WaveFormat.AverageBytesPerSecond / 1000;

                    int startPos = (int)cutFromStart.TotalMilliseconds * bytesPerMillisecond;
                    startPos = startPos - startPos % reader.WaveFormat.BlockAlign;

                    int endBytes = (int)cutFromEnd.TotalMilliseconds * bytesPerMillisecond;
                    endBytes = endBytes - endBytes % reader.WaveFormat.BlockAlign;
                    int endPos = (int)reader.Length - endBytes;

                    TrimWavFile(reader, writer, startPos, endPos);
                }
            }
        }

        private static void TrimWavFile(WaveFileReader reader, WaveFileWriter writer, int startPos, int endPos)
        {
            reader.Position = startPos;
            byte[] buffer = new byte[1024];
            while (reader.Position < endPos)
            {
                int bytesRequired = (int)(endPos - reader.Position);
                if (bytesRequired > 0)
                {
                    int bytesToRead = Math.Min(bytesRequired, buffer.Length);
                    int bytesRead = reader.Read(buffer, 0, bytesToRead);
                    if (bytesRead > 0)
                    {
                        writer.WriteData(buffer, 0, bytesRead);
                    }
                }
            }
        }

New Post: DataChunk header in wrong position

$
0
0
this will most likely by that NAudio writes a WAVEFORMATEX structure rather than a WAVEFORMAT structure. It has two more bytes. This really shouldn't be a problem with other software.

New Post: DataChunk header in wrong position

$
0
0
The other program, that I did not write, is using the files for analysis, the files it reads for some reason does not like the 2 extra bytes. It just crashes. Is there a way to do a WAVEFORMAT through NAudio or a way to alter the file programmatically instead of the extra few steps? Not looking for a handout just if it is possible and possibly point me in the right direction?

New Post: DataChunk header in wrong position

$
0
0
the problem is that it's fairly hard-coded into WaveFormat.Serialize. However, you could create your own custom WaveFormat class that derives from WaveFormat and overrides Serialize to not write the extraSize. Something like this (not tested)
        public override void Serialize(BinaryWriter writer)
        {
            writer.Write((int)(16 + extraSize)); // wave format length
            writer.Write((short)Encoding);
            writer.Write((short)Channels);
            writer.Write((int)SampleRate);
            writer.Write((int)AverageBytesPerSecond);
            writer.Write((short)BlockAlign);
            writer.Write((short)BitsPerSample);
        }

New Post: DataChunk header in wrong position

$
0
0
oh boy this will be interesting lol. I really appreciate the help! Now to see if I can figure out how to do something like that :)

New Post: DataChunk header in wrong position

$
0
0
Thank you so much! I believe this to have worked. I have not extensively tested the solution but it has not crashed my program when trying to run a file!

Much Appreciated

New Post: how to play gsm and dss files using NAudio

New Post: VB.NET - Buffer full TCP-Server

$
0
0
Thank you very much for your patience.
It was a problem in the while loop, but now works.

New Post: VB.NET - Buffer full TCP-Server

$
0
0
great, glad you have it working now

New Post: WaveOut Volume (Network-Chat)

$
0
0
Hey did I can change the volume of output from received bytes?
I have found WaveOut.Volume but is not allow great 1 and when i change in the source-code so has not a influence for the output.
Notice: I have a Network-Chat not a MP3-File!

What should I do?

Thank your for any replies.

Created Unassigned: StereoWaveformPainter winforms control [16478]

$
0
0
Hi,

I made a new winform waveformpainter control, see file attached. Perhaps you want to include it Mark.

Kind regards
Freefall

New Post: Facing issue when recording audio over virtual machines "no driver calling waveinprepareheader".

$
0
0
in the application that i am working on the users record audio from a thin client .. waveIn works fine for short 10 - 20 secs recordings but for anything over 40 - 50 seconds i get an error - "no driver calling waveinprepareheader".

i am using the standard code from the NAudio demo solution.

Would really appreciate help on this. Have been racking my brains out for days now.

New Post: Getting real time values from a MIDI file

$
0
0
I've been trying to get the exact real time values from MIDI files in order to use the data in my Guitar Hero style game. I've successfully managed to get it to work, but as soon as a tempo change occurs that changes the tempo greatly (think 125BPM to 117BPM) I start getting really big values which are way off, and then when the BPM goes back to 125 the values go back to normal.
float time = (note.AbsoluteTime / midiFile.DeltaTicksPerQuarterNote) * (currentMicrosecondsPerQuarterNote / 1000000f);
That is what I've been using, and if possible could someone either explain what's wrong or tell me how to fix it?

New Post: NAudio for windows phone 8 App?

$
0
0
Hi, Mark!

First off, thanks for providing such a great audio library, it's absolutely superb!

I'm building a windows phone app that will need to do some serious audio handling. If I recall correctly, the current full version of NAudio can't be used in a windows phone app due to the no-ACM restrictions on windows store apps. Is there a new version under way that I might be able to use when it's released?

Again, thanks for all your hard work on this!

Frauke

New Post: C# 8 BIT WAV (non RIFF) to MP3 conversion makes 0 bit MP3 - HELP!

$
0
0
       using (var reader = new WaveFileReader(wavFile))
                    {

                       var converter = WaveFormatConversionStream.CreatePcmStream(reader);
                        var newFormat = new WaveFormat(44100, 16, 2);

                        using (var conversionStream = new WaveFormatConversionStream(newFormat, converter))
                        using (var wtr = new LameMP3FileWriter(mp3FileName, conversionStream.WaveFormat, LAMEPreset.VBR_90))
                        {
                            conversionStream.CopyTo(wtr);
                        }
                        reader.Close();

New Post: NAudio for windows phone 8 App?

$
0
0
hey Frauke,
I would love to bring NAudio to WCM at some point in the future. I'm hoping that with the arrival of Windows 10, that should get easier to do. We already have some support for Windows 10, and in theory most of the same code should be reusable on the phone. There are also some new audio APIs coming with Win 10.

New Post: Getting real time values from a MIDI file

$
0
0
I think you have to take into account historic tempo changes in order to successfully convert MIDI ticks into absolute time in seconds. So unfortunately, there is no easy way. Basically each note has a delta number of ticks, and so its time must be calculated based on the time of the previous event.
Viewing all 5831 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>