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

New Post: Need a function urgently

$
0
0

Hi Mark,

Thanks for taking the time to help me out. I am very confused about this (sorry)

My structure is like this:

I start out with a list of file names. From the filenames, I create an array of meteringsamplesproviders like so: (Note, this is just pseudo code, just to show what I am trying to do)

MeteringSampleProvider[] SamplesBeforeMixdown  = new MeteringSampleProvider(new AudioFileReader([FileNames.Count]));

for(int n = 0; n<FileNames.count;n++)

{

MeteringSampleProvider input = new MeteringSampleProvider(new AudioFileReader(FileNames[n]));

SamplesBeforeMixdown[n] = input;

}

Then I pass the array to my MixingMultiplexingSampleProvider, like this:

MixingMultiplexingSampleProvider sampleprovider = new MixingMultiplexingSampleProvider(SamplesBeforeMixdown, WaveOut.GetCapabilities(playbackDeviceNumber).Channels);

Also, I made changes to the MeteringSampleProvide class in order to store offset / channels, so that I can link each sample provider in the array to a waveformpainter control. (I catch the StreamVolume event in order to draw the wave in the waveformpainter. So I till need to access the UI controls as well.

I am completely confused now as to where/how I need to implement looping. I'm slightly new to this, so sorry for all the questions...

Thanks!


New Post: Need a function urgently

$
0
0

I created the following class: 

publicclass MyLoopingSampleProvider : ISampleProvider 
    {
        AudioFileReader audiofilereader;///<summary>/// Initializes a new instance of MyLoopingSampleProvider///</summary>///<param name="filename">the path to a sound file</param>public MyLoopingSampleProvider(string filename)
        {
            audiofilereader = new AudioFileReader(filename);
        }///<summary>/// Reads samples from this sample provider///</summary>///<param name="buffer">Sample buffer</param>///<param name="offset">Offset into sample buffer</param>///<param name="sampleCount">Number of samples desired</param>///<returns>Number of samples read</returns>publicint Read(float[] buffer, int offset, int count)
        {int bytesread = 0;

            bytesread = audiofilereader.Read(buffer, offset, count);

            if (bytesread == 0)
            {
                audiofilereader.Position = 0;
                bytesread = audiofilereader.Read(buffer, offset, count);
            }return bytesread; 
        }///<summary>/// WaveFormat///</summary>public WaveFormat WaveFormat
        {get { return audiofilereader.WaveFormat; }
        }

    }
 

Not the Read function: When no bytes were returned, it will set the audiofilereader to 0, and just read again.

Then I do like this: For each file in my input array, I'll create the MyLoopingSampleProvider. With the output, I create a meteringsampleprovider (For painting the input waves).

With the array of meteringsampleproviders from above, I then create the mixingmultiplexingsampleprovider.

The output from the mixingmultiplexingsampleprovider is then in turn used to create a meteringsampleprovicer (for painting the output waves).

Finally tha last meteringsampleprovider is used for playing as a waveout.

When I choose only one stereo wavefile as input, it plays twice, then stops. When I choose 2 stereo inputs, it plays 1 and a half times, then stops. When I choose 3 inputs, it plays once, but never repeats.

When I play the MyLoopingSampleProvider directly, (iow without creating the metering and/or MixingMultiplexingSampleProvider it will loop correctly, with no problems.

Am I at least on the right track with what I am doing?

Will I be able to use this method for multiple files with different durations? What it needs to do is to keep playing until the longest sound has finished, then loop all of them at the same time. In other words, it should not loop a shorter file while a longer file is still playing.

Any help will be very much appreciated!

Thanks!

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

Hi, I also seem to run into this problem running the NAudio Demo on Windows 8 when I set the target framework to be 4.0 or 4.5. If I set the target framework to be 3.5, it works fine. I did not have this problem under Windows 7 even with .Net 4.0.

I haven't found a way around this and am quite stuck right now. Hope this helps!

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

in the NAudio demo app, can you go to the ACM codec tab and see what codecs you have installed. Also are you running 32 bit or 64 bit (the executable, not your OS)

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

It crashes when I try to access it. I run in 32 bit.

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

that is very strange. I am using WIndows 8, and I have no problem running NAudio demo in any version of .NET (I've tried 4.0 and 4.5). What line does it crash on? Is there a stack trace?

Mark

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

No I don't have a stack trace as the program just crashes. I debugged to see where the problem seemed to be and it seems to occur in the WaveFormatCustomMarshaler when this is called :

in

WaveFormat�SuggestPcmFormat(WaveFormat�compressedFormat)
{
..
MmException.Try(AcmInterop.acmFormatSuggest(IntPtr.Zero,�compressedFormat,�suggestedFormat,�Marshal.SizeOf(suggestedFormat),�AcmFormatSuggestFlags.FormatTag),�"acmFormatSuggest");

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

Enabling unmanaged code debugging gives me this : 

Unhandled exception at 0x57fc2170 in NAudioDemo.exe: 0xC0000005: Access violation.

 	msaud32_divx.acm!57fc2170() 	
 	[Frames below may be incorrect and/or missing, no symbols loaded for msaud32_divx.acm]	
 	msaud32_divx.acm!57fbf195() 	
 	ntdll.dll!77ea2846() 	
 	ntdll.dll!77ea2893() 	
 	ntdll.dll!77ea9cb3() 	
 	ntdll.dll!77ea9b87() 	
 	ntdll.dll!77ea9b10() 	
 	ntdll.dll!77eaa247() 	
 	ntdll.dll!77ea7229() 	
 	KernelBase.dll!7741e7db() 	
 	winmmbase.dll!74cf38be() 	
 	kernel32.dll!77c1f939() 	
 	winmmbase.dll!74cf3e87() 	
 	ntdll.dll!77e91348() 	
 	ntdll.dll!77e6075a() 	
 	ntdll.dll!77e606bd() 	
 	winmmbase.dll!74cf45a7() 	
 	winmmbase.dll!74cf43d4() 	
 	msacm32.dll!73d220d6() 	
 	msacm32.dll!73d220e9() 	
 	msacm32.dll!73d22b04() 	
 	msacm32.dll!73d22dea() 	
 	ntdll.dll!77e9f670() 	
 	ntdll.dll!77e9f62e() 	
 	ntdll.dll!77e9f670() 	
 	ntdll.dll!77e9f62e() 	
 	ntdll.dll!77f2d04a() 	
 	ntdll.dll!77ed8b2a() 	
 	[External Code]	
>	NAudio.dll!NAudio.Wave.Compression.AcmDriver.EnumerateAcmDrivers() Line 133 + 0x2e bytes	C#
 	NAudioDemo.exe!NAudioDemo.AcmPanel.AcmForm_Load(object sender = {NAudioDemo.AcmPanel}, System.EventArgs e = {System.EventArgs}) Line 23 + 0x6 bytes	C#
 	[External Code]	
 	NAudioDemo.exe!NAudioDemo.MainForm.buttonLoadDemo_Click(object sender = {SelectedItem = Cannot evaluate expression because a native frame is on top of the call stack.}, System.EventArgs e = {X = 90 Y = 48 Button = Left}) Line 39 + 0x21 bytes	C#
 	NAudioDemo.exe!NAudioDemo.MainForm.listBoxDemos_DoubleClick(object sender = {SelectedItem = Cannot evaluate expression because a native frame is on top of the call stack.}, System.EventArgs e = {X = 90 Y = 48 Button = Left}) Line 55 + 0xe bytes	C#
 	user32.dll!76fa77d8() 	
 	user32.dll!76fa78cb() 	
 	user32.dll!76fa787a() 	
 	user32.dll!76fa899d() 	
 	user32.dll!76fa8a66() 	
 	[External Code]	
 	NAudioDemo.exe!NAudioDemo.Program.Main() Line 26 + 0x8 bytes	C#
 	mscoreei.dll!7397f5a3() 	
 	kernel32.dll!77c24c95() 	
 	mscoree.dll!739f7f16() 	
 	mscoree.dll!739f4de3() 	
 	kernel32.dll!77c28543() 	
 	ntdll.dll!77eaac69() 	
 	ntdll.dll!77eaac3c() 	

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

interesting, looks like you have a divx ACM codec that might be causing the problem. Perhaps its largest WaveFormat size is bigger than the maximum I had allocated (with WaveFormatExtraData). Having said that I can't see how that would cause an access violation.

Are you able to debug against the actual NAudio source code? You could put breakpoints on WaveFormat.MarshalFromPtr and WaveFormat.MarshalToPtr. You could also see if WaveFormatCustomMarshaller.GetNativeDataSize is being called. Perhaps that is a problem.

Source code checked in, #9b2756c48984

$
0
0
experimental support for Win8 store app audio capture. Currently getting device in use errors

Source code checked in, #2228755d82a5

$
0
0
got request microphone permission working

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

I can confirm that MarshalToPtr is being called, and that GetNativeDataSize never is. Since I also crash with the line :

AcmInterop.acmDriverEnum(new AcmInterop.AcmDriverEnumCallback(DriverEnumCallback), IntPtr.Zero, 0);

I'm not sure the problem is with WaveFormat.

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

is DriverEnumCallback getting called? Can you try putting a breakpoint on that?

Mark

New Post: AcmNotPossible calling acmStreamOpen

Commented Issue: Playing Short Audio Files [16377]

$
0
0
I'm writing a game and I'd like to use NAudio to add sound to it. I followed a few examples and was rather pleased with NAudio's API and performance.

I ran into the following issue: NAudio will not play short audio files. I've used WaveChannel32.Length to get the following numbers.
Files with length 755712 or less will not play.
Files with length 5935104 do play.
I'm not sure where the exact limit is. There are no exceptions thrown. I was hoping to use NAudio to play files of about 1 second long. Is anyone else having this issue? Is there a fix? Do I need to find a different library?
Comments: Losing the WaveMixerStream32 helped a lot! Thanks. The short files now play nicely. Here's my current rapid-hack code: WaveOut playbackDevice = new WaveOut(); AudioFileReader samp2 = new AudioFileReader(<FileOne>); AudioFileReader samp3 = new AudioFileReader(<FileTwo>); MixingSampleProvider mixy = new MixingSampleProvider(new List<ISampleProvider> { samp2, samp3 }); playbackDevice.Init(new SampleToWaveProvider(mixy)); playbackDevice.PlaybackStopped += Stopped; playbackDevice.Play(); Thread.Sleep(TimeSpan.FromSeconds(60.0)); // Prevent program from closing before files are done. Function Stopped simple prints "Stopped" to the terminal. If I put 1-second files in one and two, it mixes them nicely. It does exactly what I want them to do. If I put 16-second files in one and two, it mixes them correctly but stops playing them after about 1 second. How come? I'd like to be able to play long music files and short effects. I imagine I'd use a MixingSampleProvider to mix it all together. I've seen it has functions: AddMixerInput, RemoveMixerInput. Perfect! But it needs to be able to handle a single 60-second file playing, and then suddenly mixing in a 1-second file. And then another! And then the same one again! Am I on the right track to getting this set up?

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

that's very strange. I guess it could be that you have a badly behaving ACM codec, but I would expect at least acmDriverEnum to work. If you go to help | about in Windows Media Player and click tech support information, what ACM codecs does it show?

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

 

Audio Codecs

TypeNameFormatBinaryVersion
ACMMicrosoft GSM 6.10 Audio CODEC0031msgsm32.acm6.2.9200.16384
ACMMicrosoft CCITT G.711 A-Law and u-Law CODEC0007msg711.acm6.2.9200.16384
ACMFraunhofer IIS MPEG Layer-3 Codec (professional)0055l3codecp.acm3.4.0.0
ACMMicrosoft IMA ADPCM CODEC0011imaadp32.acm6.2.9200.16384
ACMMicrosoft ADPCM CODEC0002msadp32.acm6.2.9200.16384
ACMMessenger Audio Codec028Esirenacm.dll15.4.3555.308
ACMMicrosoft PCM Converter0001

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

interesting, there is no msaud32_divx.acm in that list. Can you try building your app targetting x64 and see what happens?

New Post: AcmNotPossible calling acmStreamOpen

$
0
0

It works now. It seems I have some cleaning up to do with the codecs I have installed. Thanks.

Commented Issue: Playing Short Audio Files [16377]

$
0
0
I'm writing a game and I'd like to use NAudio to add sound to it. I followed a few examples and was rather pleased with NAudio's API and performance.

I ran into the following issue: NAudio will not play short audio files. I've used WaveChannel32.Length to get the following numbers.
Files with length 755712 or less will not play.
Files with length 5935104 do play.
I'm not sure where the exact limit is. There are no exceptions thrown. I was hoping to use NAudio to play files of about 1 second long. Is anyone else having this issue? Is there a fix? Do I need to find a different library?
Comments: what type of application are you running? A console app? In which case you should be using WaveOutEvent
Viewing all 5831 articles
Browse latest View live


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