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

New Post: DmoResamplerStream E_NOINTERFACE

$
0
0
I just wanted to use the DmoResamplerStream and I tested it in a Console application. So the default apartment mode is MTA. The result was that it does its job.
But if I chance the main thread to an STA thread it throws exceptions in the read method.
I would guess that the problem is, that I create the com interfaces on a sta-thread and use it in a mta-thread(e.g. directsound calls read on a mta-thread).

Just take a look at this code:
        [MTAThread]
        static void Main(string[] args)
        {
            DirectSoundOut dsound = new DirectSoundOut();
            Mp3FileReader reader = new Mp3FileReader(@"C:\Temp\test.mp3");
            dsound.Init(new ResamplerDmoStream(reader, new WaveFormat(48000, 16, 2)));
            dsound.Play();

            Console.ReadKey();
        }
Now if you change the MTAThreadAttribute to STAThreadAttribute what would equals to a gui-thread it throws an exception in the read-"callback".

New Post: DmoResamplerStream E_NOINTERFACE

$
0
0
You have to use the resampler on the thread that it is created in. This is a very annoying problem to work around but it is possible. However, why do you need resampling in this instance? DirectSound does it for you anyway.

New Post: Mute linein

$
0
0
Hi there. Thanks for this great library. I just encountered the same problem as kward. Using the MixerControlType.Mute works for mute but not for un-mute. Will there be a fix for this issue in future releases? I just want to know if someone is working on that before I might start diving into that part of the code.

Thanks,
Markus

New Post: DmoResamplerStream E_NOINTERFACE

$
0
0
Its just a test so simulate multithreading for that interface. How would you work around it?
And is there the same problem with MFTs?

New Post: DmoResamplerStream E_NOINTERFACE

$
0
0
the way I work around it with the MediaFoundationReader is to optionally recreate the MFT in the first call to Read if it comes in on another thread. With a Resampler you can just wait until the first call to Read to create it since all calls to Read come from the same thread with DirectSoundOut.

New Post: DmoResamplerStream E_NOINTERFACE

$
0
0
Well thats a quite ugly solution :(
Have you ever thought about using the CallI IL-Instruction instead of the traditional way of implementing com-interfaces. That would solve all these problems. If I am right, I already told you about it some time ago :)
It is quite anoying to create all these complicated work arounds.

New Post: NAudio third-party dependencies

$
0
0
markheath wrote:
You need some way of talking to the audio hardware to play or record audio, so you have to call into unmanaged APIs at some point. There are parts of NAudio that are fully manged though, such as the ability to read and write WAV files.
Does that mean that you can't run NAudio on a headless server with no sound card in it? I'm looking to do some bulk processing from a server, not a desktop PC and want to be able to use NAudio to do conversions.

Is there a list of external dependencies that may not be present?

New Post: NAudio third-party dependencies

$
0
0
sure, you can use the parts of NAudio that don't need a soundcard. You just can't play audio or record it. If you are converting audio from one format to another for example, you have no need of a soundcard, just whatever codecs you plan to use,.

Commented Unassigned: 32bit PCM into 16bit PCM [16397]

$
0
0
How can i convert 32 bit PCM wave into 16 bit PCM??

I was making software to record system volume using LoopBackCapture. Its capturing data of 32 bit PCM ( 32 bit PCM: 48kHz 2 channels wBitsPerSample:32 dwChannelMask:3 subFormat:00000003-0000-0010-8000-00aa00389b71 extraSize:22 )

I want to convert it into a 16 bit stereo data....I am not able to get it...

Its my code to convert the data from 32 bit PCM into 16 bit PCM. I am getting some noises and some real song data. Need help...

```
Private Function FX32TO16(ByVal input As Byte(), ByVal len As Integer) As Byte()
Dim output As Byte() = New Byte(len / 2 - 1) {}
Dim outputIndex As Integer = 0
For n As Integer = 0 To len - 1 Step 4
output(outputIndex) = input(n + 2)
output(outputIndex + 1) = input(n + 3)
outputIndex += 2
Next
Return output
End Function
```
Comments: Captured data is in 32 bit int format.... From my above function FX32TO16, i can only hear little bit sound and so much noise.... I am sending the sound or music currently being played on pc/laptop to my android phone...which can only play 16 bit stereo or mono waves...32 bit waves are still not possible on android using audioTrack class... So i need to convert the 32 bit int data into 16 bit...without any noise...

Commented Unassigned: 32bit PCM into 16bit PCM [16397]

$
0
0
How can i convert 32 bit PCM wave into 16 bit PCM??

I was making software to record system volume using LoopBackCapture. Its capturing data of 32 bit PCM ( 32 bit PCM: 48kHz 2 channels wBitsPerSample:32 dwChannelMask:3 subFormat:00000003-0000-0010-8000-00aa00389b71 extraSize:22 )

I want to convert it into a 16 bit stereo data....I am not able to get it...

Its my code to convert the data from 32 bit PCM into 16 bit PCM. I am getting some noises and some real song data. Need help...

```
Private Function FX32TO16(ByVal input As Byte(), ByVal len As Integer) As Byte()
Dim output As Byte() = New Byte(len / 2 - 1) {}
Dim outputIndex As Integer = 0
For n As Integer = 0 To len - 1 Step 4
output(outputIndex) = input(n + 2)
output(outputIndex + 1) = input(n + 3)
outputIndex += 2
Next
Return output
End Function
```
Comments: you need to understand audio bit depths if you want to write the conversion code yourself. You can't just throw away two out of every four bytes and expect it to work. Please read my article here for more information: http://www.codeproject.com/Articles/501521/How-to-convert-between-most-audio-formats-in-NET Alternatively, just use WaveFloatTo16Provider

Commented Unassigned: 32bit PCM into 16bit PCM [16397]

$
0
0
How can i convert 32 bit PCM wave into 16 bit PCM??

I was making software to record system volume using LoopBackCapture. Its capturing data of 32 bit PCM ( 32 bit PCM: 48kHz 2 channels wBitsPerSample:32 dwChannelMask:3 subFormat:00000003-0000-0010-8000-00aa00389b71 extraSize:22 )

I want to convert it into a 16 bit stereo data....I am not able to get it...

Its my code to convert the data from 32 bit PCM into 16 bit PCM. I am getting some noises and some real song data. Need help...

```
Private Function FX32TO16(ByVal input As Byte(), ByVal len As Integer) As Byte()
Dim output As Byte() = New Byte(len / 2 - 1) {}
Dim outputIndex As Integer = 0
For n As Integer = 0 To len - 1 Step 4
output(outputIndex) = input(n + 2)
output(outputIndex + 1) = input(n + 3)
outputIndex += 2
Next
Return output
End Function
```
Comments: I tried using WaveFloatTo16Provider, but it was throwing an error something like" ieee float value expected"...

Commented Unassigned: 32bit PCM into 16bit PCM [16397]

$
0
0
How can i convert 32 bit PCM wave into 16 bit PCM??

I was making software to record system volume using LoopBackCapture. Its capturing data of 32 bit PCM ( 32 bit PCM: 48kHz 2 channels wBitsPerSample:32 dwChannelMask:3 subFormat:00000003-0000-0010-8000-00aa00389b71 extraSize:22 )

I want to convert it into a 16 bit stereo data....I am not able to get it...

Its my code to convert the data from 32 bit PCM into 16 bit PCM. I am getting some noises and some real song data. Need help...

```
Private Function FX32TO16(ByVal input As Byte(), ByVal len As Integer) As Byte()
Dim output As Byte() = New Byte(len / 2 - 1) {}
Dim outputIndex As Integer = 0
For n As Integer = 0 To len - 1 Step 4
output(outputIndex) = input(n + 2)
output(outputIndex + 1) = input(n + 3)
outputIndex += 2
Next
Return output
End Function
```
Comments: I'm pretty sure you already have IEEE float so just use that as your WaveFormat for the IWaveProvider you pass into the converter

New Post: Converting RTP Packets into wav format and writing to a wav file dynamically

$
0
0
You were right on money Mark. By removing the RTP headers from the RTP packets I am able to generate the PCM stream for MuLaw and write it to a WAV file which plays fine without the clicking noise. After going through your code I realized that currently your code only supports conversion of raw data into PCM stream for the G711 MuLaw and Alaw formats. Am I correct? If I want to use other formats such as G729 etc. is there a way to modify your code and convert raw data for such formats into PCM stream? Any tips on that would be really helpful.

Thanks a lot..

Regards
Saleh

New Post: Converting RTP Packets into wav format and writing to a wav file dynamically

New Post: DmoResamplerStream E_NOINTERFACE

$
0
0
I don't know about the technique you mention. By all means see if you can prototype it and see if it does solve the problems.

Mark

New Post: 10 band Equalizer

$
0
0
Hi Robert,

I have just completed a WPF prototype 10 band equaliser using yuvalnv's code on Google code as a starting point. The one thing I haven't quite got working yet is when you drag the thumb on a slider to keep the audio stream going. At the moment I have to pause the play, set the new values then start the play again. It's an inconvenience I would like to overcome.

Thinking one has to buffer the stream.

Jim.

New Post: Change Volume of Mp3 during play

$
0
0
I can play Mp3 just fine from the example in the Documentation. However, Is it possible to update the Volume to the IWavePlayer via the WaveChannel32 while it is playing?? I was gong to write a handler from the + - keys on the keyboard or I am wasting time?

New Post: Change Volume of Mp3 during play

$
0
0
Yes, if you keep hold of the instance of WaveChannel32. It might be easier for you to use the AudioFileReader which has a Volume property. Note that there is a difference between adjusting volume at the sample level (which is what WaveChannel32 and AudioFileReader do) and adjusting volume at the device level (which is what WaveOut.Volume does for instance). Not all output driver models support changing device volume.

New Post: Release build of NAudio 1.5

$
0
0
I have a problem with a .wav-file that has an invalid chunk length in its header. In the WaveFileReader.cs the section
                if (chunkLength < 0 || chunkLength > stream.Length - stream.Position)
                {
                    Debug.Assert(false, String.Format("Invalid chunk length {0}, pos: {1}. length: {2}",
                        chunkLength, stream.Position, stream.Length));
                    // an exception will be thrown further down if we haven't got a format and data chunk yet,
                    // otherwise we will tolerate this file despite it having corrupt data at the end
                    break;
                }
causes a popup-window because of the debug assertion. However, the .wav-file can be played without a problem. So I guess NAudio 1.5 is a debug-build. Is it possible to deliver NAudio 1.5 as a release-build instead of the debug version? That would help a lot.

Thanks & Best regards
Kay

New Post: Release build of NAudio 1.5

$
0
0
hi Kay, I'd recommend switching to NAudio 1.6 which is a release build. If you really must have 1.5, then rebuild the source in Release mode.
Viewing all 5831 articles
Browse latest View live


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