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

New Post: Volume Meter

$
0
0

hi,

   It tell to create a pannel...

i need to use it in a form...

private SampleProvider CreateInputStream(string

fileName)

 

 

Thanks & Regards,

HInshin


New Post: Volume Meter

$
0
0

the exact same code will work in a form.

New Post: Volume Meter

$
0
0

Hi,

   can you please tell me the sample code for that ... I tried a lot but I was not able to find that . please tell the solution.

 

Thanks & Regards,

 

Hinshin 

New Post: Create a playlist?

$
0
0

Hi,

I am starting with NAudio, i need to create a Playlist.  Does NAudio provide functions to create a playlist of X songs?.

 

thanks a lot.

New Post: NAudio can't play some mp3 streaming

$
0
0

I wrote a software with NAudio demo that play steaming MP3 file. I found that NAudio can play most of MP3 file, but can't work with some MP3 file. I checked the sampling rate and bit rate of MP3 files, and there are not difference.

New Post: Volume Meter

$
0
0

 

Hi,

   can you please tell me the sample code for that ... I tried a lot but I was not able to find that . please tell the solution.

 

Thanks & Regards,

 

Hinshin 

New Post: MediaFoundation CreateWaveFormatFormMediaType

$
0
0

I took the time to check with the documentation and with some audio files.

This version is probably better fit.

 

[DllImport("mfplat.dll", ExactSpelling = true, PreserveSig = false)]internalstaticexternvoid MFCreateWaveFormatExFromMFMediaType
(
	IMFMediaType pMFType,out WaveFormatExtensible wf,outint pcbSize,int flags = 0
);publicstatic WaveFormat CreateWaveFormatFromMediaType(IMFMediaType mediatype)
{
	WaveFormatExtensible wF;int pcbSize = 0;	
	MFCreateWaveFormatExFromMFMediaType(mediatype, out wF, out pcbSize);if (wF.Encoding == WaveFormatEncoding.Extensible)return wF;else
	{var xx = (WaveFormat)wF;return xx;
	}
}

New Post: NAudio can't play some mp3 streaming

$
0
0

what do you mean "can't work"? What error message do you get?


New Post: NAudio can't play some mp3 streaming

$
0
0

This is my code:

 private void PlayMP3Stream(byte[] mp3Bytes)       

{           

using (MemoryStream responseStream = new MemoryStream(mp3Bytes))           

{               

var readFullyStream = new ReadFullyStream(responseStream);               

frame = Mp3Frame.LoadFromStream(readFullyStream);
                if (decompressor == null)               

{                   

NAudio.Wave.WaveFormat waveFormat = new Mp3WaveFormat(frame.SampleRate, frame.ChannelMode == ChannelMode.Mono ? 1 : 2, frame.FrameLength, frame.BitRate);                   

decompressor = new AcmMp3FrameDecompressor(waveFormat);                   

this.bufferedWaveProvider = new BufferedWaveProvider(decompressor.OutputFormat);                   

this.bufferedWaveProvider.BufferDuration = TimeSpan.FromSeconds(20); // allow us to get well ahead of ourselves                   //this.bufferedWaveProvider.BufferedDuration = 250;                }

                int decompressed = decompressor.DecompressFrame(frame, buffer, 0);               

bufferedWaveProvider.AddSamples(buffer, 0, decompressed);           

}       

}

New Post: NAudio can't play some mp3 streaming

$
0
0

 private void udpReceive()       

{           

try           

{               

playMP3Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);               

playIPEP = new IPEndPoint(CQCCRI.Common.Utility.GetLocalIPV4Address(), Settings.Default.DefaultMulticastPort);               playMP3Server.Bind(playIPEP);               

playMP3Server.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption(playPoint.Address, CQCCRI.Common.Utility.GetLocalIPV4Address()));               

playMP3Server.ReceiveTimeout = Settings.Default.PlayReceiveTimeout;

                playbackState = StreamingPlaybackState.Buffering;
                while (true)               

{                   

byte[] data = new byte[1024 * 10];                   

int length = this.playMP3Server.Receive(data);                   

byte[] mp3Bytes = new byte[length];                   

Array.Copy(data, 0, mp3Bytes, 0, mp3Bytes.Length);                   

PlayMP3Stream(mp3Bytes);
              }           

}           

catch (Exception) {     }       

}

New Post: NAudio can't play some mp3 streaming

$
0
0

I debug the code step by step in VS2012, when NAudio stop playing steaming, I got NAudio mMException in VS.

New Post: NAudio can't play some mp3 streaming

$
0
0

NAudio.MmException: AcmNotPossible calling acmStreamConvert

New Post: NAudio can't play some mp3 streaming

$
0
0

I suspect you have a change of sample rate / channels within the file

for each frame in your MP3 file, output to debug frame.SampleRate, and  frame.ChannelMode , and see what the values for the one that fails are

New Post: MediaFoundation CreateWaveFormatFormMediaType

$
0
0

It really will have to be WaveFormatExtraData or a WaveFormat using NAudio's WaveFormatCustomMarshaller. The trouble is, waveformats can be any length, so you must use a class that is big enough to hold the largest possible WaveFormat, otherwise the marshaller will not copy all the data across. However, for Windows 8 store apps, the custom marshaller cannot be used, so it might mean I have to use an IntPtr, and manually choose which derived WaveFormat class to marshal it into.

New Post: Volume Meter

$
0
0

This is the important bit in the demo - we wrap our input stream in a MeteringSampleProvider, and subscribe to stream volume

            var postVolumeMeter = new MeteringSampleProvider(waveChannel);
            postVolumeMeter.StreamVolume += OnPostVolumeMeter;

Then in the event handler, set the value of your volume meter:

        void OnPostVolumeMeter(object sender, StreamVolumeEventArgs e)
        {
            // we know it is stereo
            volumeMeter1.Amplitude = e.MaxSampleValues[0];
            volumeMeter2.Amplitude = e.MaxSampleValues[1];
        }


New Post: How to code circullar buffer to create a delay and used the wavein for micrcophone and output to speaker?

$
0
0

if the play speed is too slow, check your waveformat. For example playing stereo audio as though it was mono can result in playback too slow.

Mark

New Post: MediaFoundation CreateWaveFormatFormMediaType

$
0
0

I had not seen WaveFormatCustomMarshaler & WaveFormatExtraData.

Gloupss Sorry, I tested this solution.

New Post: Create a playlist?

$
0
0

hi , NAudio has no built-in playlist feature, but you can make one by either handling the playback stopped event to trigger the next file, or writing your own custom IWaveProvider/ISampleProvider that moves from one file to the next when it detects the end of one.

Mark

New Post: MediaFoundation CreateWaveFormatFormMediaType

$
0
0

 

I change my routine somewhat.
I do not have audio file with ExtraData to complementary tests.


[DllImport("mfplat.dll", ExactSpelling = true, PreserveSig = false)]internalstaticexternvoid MFCreateWaveFormatExFromMFMediaType
(
	IMFMediaType pMFType,out IntPtr wf,outint pcbSize,int flags = 0
);publicstatic WaveFormat CreateWaveFormatFromMediaType(IMFMediaType mediatype)
{
	IntPtr ptr;int pcbSize = 0;
	MFCreateWaveFormatExFromMFMediaType(mediatype, out ptr, out pcbSize);return WaveFormat.MarshalFromPtr(ptr);
}

New Post: MediaFoundation CreateWaveFormatFormMediaType

$
0
0

It is formats like MP3, AAC (and some types of ADPCM) that tend to have extra data after the WaveFormat structure. The most I have ever seen is about 40 bytes. You could perhaps enumerate all MF decoder's input media types and create their WaveFormat's and see what the largest value of pcbSize you get is.

Viewing all 5831 articles
Browse latest View live


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