<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="/rss.xsl"?><rss version="2.0"><channel><title>naudio Forum Rss Feed</title><link>http://www.codeplex.com/naudio/Thread/List.aspx</link><description>naudio Forum Rss Description</description><item><title>New Post: change  left or Right channel volume.</title><link>http://naudio.codeplex.com/discussions/443454</link><description>&lt;div style="line-height: normal;"&gt;It work all right for single song. When go to next song then it is reset. what i doing now?&lt;br /&gt;
&lt;/div&gt;</description><author>SudipDas</author><pubDate>Sat, 18 May 2013 08:21:45 GMT</pubDate><guid isPermaLink="false">New Post: change  left or Right channel volume. 20130518082145A</guid></item><item><title>New Post: Custom sample provider FFT sample capture issue</title><link>http://naudio.codeplex.com/discussions/443374</link><description>&lt;div style="line-height: normal;"&gt;I'm new at audio processing so you will have to forgive my ignorance.&lt;br /&gt;
&lt;br /&gt;
I took a look at WaveFormat.BlockAlign. It only has a getter and the value was &amp;quot;4&amp;quot; when I retrieved it (I have been trying to figure out exactly what that pertains to).&lt;br /&gt;
&lt;br /&gt;
frame: audio information for a given point in time.&lt;br /&gt;
&lt;br /&gt;
The problem I seem to be having is the FFT calculation only happens 10 - 11 times per second and trying to time it correctly is... difficult.&lt;br /&gt;
&lt;br /&gt;
If I rely on notifications, I get 10 - 11 (currently), one right after the other, then nothing for 1 second. So, I tried setting my timer to 100ms, which seemed to give me the correct data, but did not run smoothly.&lt;br /&gt;
&lt;br /&gt;
I do need to get a better understanding of how the underlying code works because when I finish this project, I will be porting over to Windows Phone 8.&lt;br /&gt;
&lt;/div&gt;</description><author>robertschoenstein</author><pubDate>Fri, 17 May 2013 19:55:18 GMT</pubDate><guid isPermaLink="false">New Post: Custom sample provider FFT sample capture issue 20130517075518P</guid></item><item><title>New Post: How would I detect drum beats in a live stream?</title><link>http://naudio.codeplex.com/discussions/443798</link><description>&lt;div style="line-height: normal;"&gt;NAudio gives you access to the raw samples. You'd need to implement your own transient detection algorithm. How simple this is depends on what sort of signal you are looking at. If you can isolate a single drum then it is not too hard. If you mic a full kit, then it would be a much more tricky problem.&lt;br /&gt;
&lt;/div&gt;</description><author>markheath</author><pubDate>Fri, 17 May 2013 18:01:40 GMT</pubDate><guid isPermaLink="false">New Post: How would I detect drum beats in a live stream? 20130517060140P</guid></item><item><title>New Post: Converting RTP Packets into wav format and writing to a wav file dynamically</title><link>http://naudio.codeplex.com/discussions/442970</link><description>&lt;div style="line-height: normal;"&gt;If it is an ACM codec you must use WaveFormatConversionStream, and if it is a Media Foundation codec you use MediaFoundationReader. It can be a bit of a pain working with custom ACM codecs- you have to examine what WaveFormat they are expecting and pass that in. The NAudioDemo project does a fair bit of the work for you in showing the input and output formats. Windows Media Player can use ACM and Media Foundation codecs so as long as the format chunk in your WAV file is correct, it should play fine.&lt;br /&gt;
&lt;br /&gt;
There is nothing stopping you putting stereo MuLaw into a WAV file. Just set up the WaveFormat with the correct values (MuLaw encoding, 2 channels, 8 bits per sample etc) and you should be fine. MuLaw is not normally stereo, since its main use is telephony&lt;br /&gt;
&lt;/div&gt;</description><author>markheath</author><pubDate>Fri, 17 May 2013 17:59:38 GMT</pubDate><guid isPermaLink="false">New Post: Converting RTP Packets into wav format and writing to a wav file dynamically 20130517055938P</guid></item><item><title>New Post: Custom sample provider FFT sample capture issue</title><link>http://naudio.codeplex.com/discussions/443374</link><description>&lt;div style="line-height: normal;"&gt;you must make sure your buffer size is block aligned (use BlockAlign on the WaveFormat).&lt;br /&gt;
I'm not quite sure what you are referring to as a &amp;quot;frame&amp;quot; in this context.&lt;br /&gt;
&lt;/div&gt;</description><author>markheath</author><pubDate>Fri, 17 May 2013 17:56:12 GMT</pubDate><guid isPermaLink="false">New Post: Custom sample provider FFT sample capture issue 20130517055612P</guid></item><item><title>New Post: System.Drawing and System.Windows.Forms references</title><link>http://naudio.codeplex.com/discussions/371274</link><description>&lt;div style="line-height: normal;"&gt;@tommck, what class in NAudio were you using that needed WinForms in Azure?&lt;br /&gt;
&lt;/div&gt;</description><author>markheath</author><pubDate>Fri, 17 May 2013 17:54:46 GMT</pubDate><guid isPermaLink="false">New Post: System.Drawing and System.Windows.Forms references 20130517055446P</guid></item><item><title>New Post: Custom sample provider FFT sample capture issue</title><link>http://naudio.codeplex.com/discussions/443374</link><description>&lt;div style="line-height: normal;"&gt;I was experimenting with WasapiOut.cs and found out the minimum supported period is 30000 (30ms). So, I did the following:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;        audioClient.Initialize(shareMode, AudioClientStreamFlags.EventCallback, audioClient.MinimumDevicePeriod, 0,
                               outputFormat, Guid.Empty);
&lt;/code&gt;&lt;/pre&gt;

It did not work. The stream latency ended up being 1.0666 seconds, which is the default.&lt;br /&gt;
&lt;br /&gt;
Exclusive mode, based on MSDN documentation of IAudioClient::Initialize, should work if I set the buffer length and periodicity to MinimumDevicePeriod. It merely errors out: Buffer size not aligned.&lt;br /&gt;
&lt;br /&gt;
What I can possibly do is, like you suggested, place the completed FftBuffers into a FIFO queue. Then I can (StreamLatency / 10000)  / FftQueue.Length = Spectrum analyzer refresh rate. Then use a timer, with period based on refresh rate, to render the FFT.&lt;br /&gt;
&lt;br /&gt;
It may not work as predicted, so I am still interested in retrieving the current frame based on a timer elapsed event.&lt;br /&gt;
&lt;/div&gt;</description><author>robertschoenstein</author><pubDate>Thu, 16 May 2013 19:19:45 GMT</pubDate><guid isPermaLink="false">New Post: Custom sample provider FFT sample capture issue 20130516071945P</guid></item><item><title>New Post: Converting RTP Packets into wav format and writing to a wav file dynamically</title><link>http://naudio.codeplex.com/discussions/442970</link><description>&lt;div style="line-height: normal;"&gt;Excellent article Mark. It took me a while to understand )).. A few questions after reading your article:&lt;br /&gt;
&lt;br /&gt;
1) NAudio will only be able to convert raw stream into PCM for ACM codecs or the ones supported by Media Foundation right? If I have a custom codec installed on my machine will ACM/MF be able to convert from that custom format into PCM? Also, I found an alternate way of generating the WAV file using your code and playing it in media player for MuLaw format. I extracted the payloads from RTP packets and stored them directly into WAV file without converting them into PCM and created the WAV header with Mulaw format information instead of PCM. I am able to play that WAV file in media player. So I believe if the correct codec is installed Media Player will automatically create the PCM stream based on the codec info in header and play it for us.  But again the question remains what will happen in case of custom codecs about which media player is unaware?&lt;br /&gt;
&lt;br /&gt;
2) Also, I want to write my audio in stereo format to a WAV file. I saw your code but it seems that stereo format writing is supported by NAudio only for PCM streams. If I want to write the MuLaw payloads in stereo format to a WAV file is there a way to do it using NAudio?&lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
Saleh&lt;br /&gt;
&lt;/div&gt;</description><author>salehk</author><pubDate>Thu, 16 May 2013 17:19:05 GMT</pubDate><guid isPermaLink="false">New Post: Converting RTP Packets into wav format and writing to a wav file dynamically 20130516051905P</guid></item><item><title>New Post: System.Drawing and System.Windows.Forms references</title><link>http://naudio.codeplex.com/discussions/371274</link><description>&lt;div style="line-height: normal;"&gt;I would like to see these references added as part of the NuGet package(s), since they're required.  It took me a long time to figure out why an Azure deployment was failing because of this :(&lt;br /&gt;
&lt;/div&gt;</description><author>tommck</author><pubDate>Thu, 16 May 2013 17:08:17 GMT</pubDate><guid isPermaLink="false">New Post: System.Drawing and System.Windows.Forms references 20130516050817P</guid></item><item><title>New Post: Custom sample provider FFT sample capture issue</title><link>http://naudio.codeplex.com/discussions/443374</link><description>&lt;div style="line-height: normal;"&gt;How about if I figure out frames per second, grab the current frame every ~40ms (needs to be a rate that is invisible to the human eye when I render) and run an FFT on that instead of relying on the buffer?&lt;br /&gt;
&lt;br /&gt;
Then my question would be: How do I get the current frame?&lt;br /&gt;
&lt;/div&gt;</description><author>robertschoenstein</author><pubDate>Thu, 16 May 2013 17:02:25 GMT</pubDate><guid isPermaLink="false">New Post: Custom sample provider FFT sample capture issue 20130516050225P</guid></item><item><title>New Post: change  left or Right channel volume.</title><link>http://naudio.codeplex.com/discussions/443454</link><description>&lt;div style="line-height: normal;"&gt;Just use the code I showed above, and add a LeftVolume and RightVolume property instead of the Volume one.&lt;br /&gt;
&lt;/div&gt;</description><author>markheath</author><pubDate>Thu, 16 May 2013 16:00:38 GMT</pubDate><guid isPermaLink="false">New Post: change  left or Right channel volume. 20130516040038P</guid></item><item><title>New Post: Custom sample provider FFT sample capture issue</title><link>http://naudio.codeplex.com/discussions/443374</link><description>&lt;div style="line-height: normal;"&gt;I want the same buffer size across all devices no matter what the soundcard supports.&lt;br /&gt;
&lt;br /&gt;
What buffer size do you recommend?&lt;br /&gt;
&lt;br /&gt;
Where do I change it?&lt;br /&gt;
&lt;br /&gt;
32ms refresh is not a necessity. It was the refresh rate I used with another audio playback library that did not support WinRT on an ARM processor.&lt;br /&gt;
&lt;/div&gt;</description><author>robertschoenstein</author><pubDate>Thu, 16 May 2013 15:04:34 GMT</pubDate><guid isPermaLink="false">New Post: Custom sample provider FFT sample capture issue 20130516030434P</guid></item><item><title>New Post: Change Volume of Mp3 during play</title><link>http://naudio.codeplex.com/discussions/443675</link><description>&lt;div style="line-height: normal;"&gt;Ok cool, that explains it. Since really this is being used as my BackGroundMusic player... I will create a proper ratio of volume values between 0 and 5 simulated visually as 0-9, and use the last volume values between 5.1 and 10 as simulated visually as 9-10... that way volume GUI slider will appear to operate much more properly to the user.&lt;br /&gt;
&lt;/div&gt;</description><author>Bixel</author><pubDate>Thu, 16 May 2013 08:57:05 GMT</pubDate><guid isPermaLink="false">New Post: Change Volume of Mp3 during play 20130516085705A</guid></item><item><title>New Post: Change Volume of Mp3 during play</title><link>http://naudio.codeplex.com/discussions/443675</link><description>&lt;div style="line-height: normal;"&gt;the difference between 5x and 10x should be 6dB, which is the same as the difference between 1x and 2x. However, by the time you've amplified that much, clipping may be reducing any further gains. A dynamic range compressor is really what you want for significant volume boosts.&lt;br /&gt;
&lt;/div&gt;</description><author>markheath</author><pubDate>Thu, 16 May 2013 08:22:17 GMT</pubDate><guid isPermaLink="false">New Post: Change Volume of Mp3 during play 20130516082217A</guid></item><item><title>New Post: Change Volume of Mp3 during play</title><link>http://naudio.codeplex.com/discussions/443675</link><description>&lt;div style="line-height: normal;"&gt;works pretty good! There is a little bit of a clipping noise when increasing volume but its not bad. One thing I noticed (or maybe its my ears) is that past a volume of 5 there seems to be no noticeable difference. It seems to take float values between 0.0 and 10.0 but again anything after 5 seems the same volume.&lt;br /&gt;
&lt;/div&gt;</description><author>Bixel</author><pubDate>Thu, 16 May 2013 08:19:44 GMT</pubDate><guid isPermaLink="false">New Post: Change Volume of Mp3 during play 20130516081944A</guid></item><item><title>New Post: Custom sample provider FFT sample capture issue</title><link>http://naudio.codeplex.com/discussions/443374</link><description>&lt;div style="line-height: normal;"&gt;OK, what is likely happening is that your soundcard is using large buffers. So when a new buffer is filled up it reads enough from the source to do several FFTs. Your options are either to work with smaller buffers, or if you really must have 32 ms, then you could put each lot of FFT results into a queue and read from that queue each 32 ms. However, you'd need to make sure the FFT buffer wasn't being reused in that case (a new one for each FFT would be needed).&lt;br /&gt;
&lt;/div&gt;</description><author>markheath</author><pubDate>Thu, 16 May 2013 06:45:00 GMT</pubDate><guid isPermaLink="false">New Post: Custom sample provider FFT sample capture issue 20130516064500A</guid></item><item><title>New Post: Custom sample provider FFT sample capture issue</title><link>http://naudio.codeplex.com/discussions/443374</link><description>&lt;div style="line-height: normal;"&gt;Followed the WPF example and still have the same issue. I used the NAudio WPF example SampleAggrigator rather than my own. Although, I stripped out the volume code; didn't need it. The spectrum analyzer is now being fed by event rather than DispatcherTimer reading directly from the SampleAggrigator.&lt;br /&gt;
&lt;br /&gt;
When I set a tracepoint; FftCalculated fired 8 times, stopped for a second, then fired 8 times, stopped for a second, and repeated this behavior.&lt;br /&gt;
&lt;br /&gt;
Updated playback engine code:&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;    public async void OpenFile(string filePath, PlaybackCallback callback)
    {
      var file = await StorageFile.GetFileFromPathAsync(filePath);

      TrackInfo = new TrackInfo
      {
        MusicProperties = await file.Properties.GetMusicPropertiesAsync(),
        Thumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem, 500)
      };

      _sampleAggregator = new SampleAggregator(4096);

      _sampleAggregator.FftCalculated += (sender, args) =&amp;gt;
        {
          if (FftCalculated != null)
          {
            Window.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =&amp;gt;
            {
              FftCalculated(sender, args);
            });
          }
        };

      var stream = await file.OpenAsync(FileAccessMode.Read);//  .OpenReadAsync();

      if (stream == null)
        return;

      using (stream)
      {
        //TODO: fix this!!!
        var task = Task.Factory.StartNew(() =&amp;gt;
          {
            _activeStream = new MediaFoundationReader(stream);
            _player = new WasapiOut(AudioClientShareMode.Shared, 200);
            Task.WaitAll(new[] { _player.Init(CreateInputStream(_activeStream)) });
          });

        Task.WaitAll(new[] { task });

        if (callback != null)
          callback(true);

        CanPlay = true;
      }
    }

    private IWaveProvider CreateInputStream(IWaveProvider fileStream)
    {
      _filterSampleProvider = new FilterSampleProvider(fileStream, _filters, true, true);

      _filterSampleProvider.SampleReady += (sender, args) =&amp;gt; 
        _sampleAggregator.Add(_filterSampleProvider.CurrentSample);

      return new SampleToWaveProvider(_filterSampleProvider);
    }
&lt;/code&gt;&lt;/pre&gt;

SampleAggrigator.cs (and FftEventArgs):&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;  public class SampleAggregator
  {
    public event EventHandler&amp;lt;FftEventArgs&amp;gt; FftCalculated;

    private readonly Complex[] fftBuffer;
    private readonly int m;

    private int fftPos;
    private float[] fftOutputBuffer;

    public int FFTLength { get; set; }

    public SampleAggregator(int fftLength = 1024)
    {
      if (!IsPowerOfTwo(fftLength))
      {
        throw new ArgumentException(&amp;quot;FFT Length must be a power of two&amp;quot;);
      }

      m = (int)Math.Log(fftLength, 2.0);
      FFTLength = fftLength;
      fftBuffer = new Complex[fftLength];
      fftOutputBuffer = new float[fftLength];
    }

    bool IsPowerOfTwo(int x)
    {
      return (x &amp;amp; (x - 1)) == 0;
    }


    public void Add(float value)
    {
      if (FftCalculated != null)
      {
        fftBuffer[fftPos].X = (float)(value * FastFourierTransform.HammingWindow(fftPos, fftBuffer.Length));
        fftBuffer[fftPos].Y = 0;
        fftPos++;

        if (fftPos &amp;gt;= fftBuffer.Length)
        {
          fftPos = 0;
          // 1024 = 2^10
          FastFourierTransform.FFT(true, m, fftBuffer);

          for (int i = 0; i &amp;lt; fftBuffer.Length / 2; i++)
          {
            // Calculate actual intensities for the FFT results.
            fftOutputBuffer[i] = (float)Math.Sqrt(fftBuffer[i].X * fftBuffer[i].X + fftBuffer[i].Y * fftBuffer[i].Y);
          }

          FftCalculated(this, new FftEventArgs(fftOutputBuffer));
        }
      }
    }
  }

  public class FftEventArgs : EventArgs
  {
    [DebuggerStepThrough]
    public FftEventArgs(float[] result)
    {
      this.Result = result;
    }

    public float[] Result { get; private set; }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;</description><author>robertschoenstein</author><pubDate>Thu, 16 May 2013 03:59:07 GMT</pubDate><guid isPermaLink="false">New Post: Custom sample provider FFT sample capture issue 20130516035907A</guid></item><item><title>New Post: Change Volume of Mp3 during play</title><link>http://naudio.codeplex.com/discussions/443675</link><description>&lt;div style="line-height: normal;"&gt;Ahh interesting.. I will experiment with all options. I am using this with XNA for a game prototype. I am using XNA's default audio library to handle UI and game sounds, but I needed something else to allow users to customize their soundtrack and NAudio seems to be doing great in that aspect. I will post my results.&lt;br /&gt;
&lt;/div&gt;</description><author>Bixel</author><pubDate>Thu, 16 May 2013 00:46:00 GMT</pubDate><guid isPermaLink="false">New Post: Change Volume of Mp3 during play 20130516124600A</guid></item><item><title>New Post: 10 band Equalizer</title><link>http://naudio.codeplex.com/discussions/438610</link><description>&lt;div style="line-height: normal;"&gt;Thanks Mark for the tip.&lt;br /&gt;
&lt;br /&gt;
Also I will take this opportunity to thank you for a great piece of work :)&lt;br /&gt;
&lt;br /&gt;
 brunp -  I'm happy to post some code up and how I tackled it a bit later.  The codes in a bit of a mess at the moment as I try to get it all working !  27 Band wow !  What frequency range are you wanting to cover with that ? &lt;br /&gt;
I thought 20-20,000Hz as standard but I have had to get somebody with younger ears to confirm some of my tests !  I can't hear that range now !&lt;br /&gt;
&lt;br /&gt;
Jim&lt;br /&gt;
&lt;/div&gt;</description><author>JamesBaker</author><pubDate>Wed, 15 May 2013 22:38:44 GMT</pubDate><guid isPermaLink="false">New Post: 10 band Equalizer 20130515103844P</guid></item><item><title>New Post: 10 band Equalizer</title><link>http://naudio.codeplex.com/discussions/438610</link><description>&lt;div style="line-height: normal;"&gt;If you are making effects for NAudio, then I strongly recommend using ISampleProvider as your base class rather than WaveStream. It will make your life much simpler. I'm hoping to get some example effects into a future version of NAudio to show what I mean.&lt;br /&gt;
&lt;/div&gt;</description><author>markheath</author><pubDate>Wed, 15 May 2013 21:17:15 GMT</pubDate><guid isPermaLink="false">New Post: 10 band Equalizer 20130515091715P</guid></item></channel></rss>