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

Closed Issue: NAudio resampler exception when deployed to Azure [16350]

$
0
0
I'm resampling wav file for my web app using ResamplerDmoStream. This works fine running locally, but I'm getting a registration error when deployed to Azure:

Exception thrown = System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {F447B69E-1884-4A7E-8055-346F74D6EDB3} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
at NAudio.Dmo.Resampler..ctor()
at NAudio.Wave.ResamplerDmoStream..ctor(IWaveProvider inputProvider, WaveFormat outputFormat)

I'm using version 1.5.4 of NAudio.dll. Thanks!
Comments: not an issue with NAudio.

New Post: Clarify WaveOutEvent.Init

$
0
0

If you call Init twice, various things that have been initialised won't be properly disposed of. It may work, but it will leak memory.

New Post: Normalize mp3 audio

$
0
0

How to use NAudio library to normalize mp3 file.

In ImpulseResponseConvolution there is normalize method, but how to normalize an mp3 file?

New Post: Exporting sample from soundfont

$
0
0

It is because the sample data is a byte array, whilst the offsets are measured in samples, which are 16 bits, so take two bytes each.

New Post: How to connect( concatenate) 2 or more .wav files in NAudio??

$
0
0

there is a FadeInOutSampleProvider recently checked into NAudio which can be used either directly, or as an example to help you with your own fading in / out. Cross-fades are also sometimes used when joining two audio files, where you fade one out and another in, with a small overlapping section.

As for documentation on samples, channels, volume, frequency, there are lots of resourses on the web if you search for phrases like "introduction to audio sampling" or "introduction to digital audio". Paul Whites' short book "Basic Digital Recording" might be worthwhile as well.

New Post: Repositioning stream using Read/Seek/Skip?

$
0
0

On streams that don't support seeking, you can only move forwards and you have to use Read.

Otherwise, setting the Position/Seek basically amount to the same thing. They are only there because WaveStream inherits from Stream which has both

Skip is just a helper method that allows you to specify duration in seconds rather than bytes. It calls Position under the hood.

New Post: Normalize mp3 audio

$
0
0

To normalize an MP3 file, you would first need to convert it to WAV (using the Mp3FileReader class). Then you perform normalisation on the samples (NAudio does not have a class that does this). Then you convert back to MP3 (using something like LAME.exe).

On the vast majority of MP3 files, normalizing would be a complete waste of time because they are already normalized. Even with quiet files, normalizing often does not have the desired effect because a single sample at maximum value anywhere in the file would mean that normalization has no effect. If you recorded the sound yourself, you should normalize before converting to MP3.

What most people who ask for normalization really want is a limiter (or a dynamic range compressor). This works by making the loudest parts of a song quieter, enabling the volume of the whole thing to be raised without clipping. But any commercial MP3s you have will already likely have been heavily limited anyway (sometimes this is called the loudness wars)

New Post: Windows 8 WinRT Metro Style Support

$
0
0

Hi Mark,

Do you have any plan to release a WinRT version of NAudio? I am currently using NAudio 1.5 in my WinRT Javascript application to convert MP3 to WAV using Naudio. It works like a charm but unfortunately the application does not pass the appcert tool certification... The tool says that naudio.dll uses some APIs that are forbidden.

I am aware it is not on your priority list but I just check.

The other idea I have is to remove from naudio source all the methods and libraries not necessary in the methods I use. Here is what I do:

public static void ConvertMp3toPcm(string sourceFilename, string outputFileName, string pcmFilename)
        {
            if (string.IsNullOrEmpty(sourceFilename))
                throw new ArgumentNullException("sourceFilename");

            if (string.IsNullOrEmpty(outputFileName))
                throw new ArgumentNullException("outputFileName");

            if (string.IsNullOrEmpty(pcmFilename))
                throw new ArgumentNullException("pcmFilename");

                using (Mp3FileReader reader = new Mp3FileReader(sourceFilename))
                {
                    using (WaveStream waveStream = WaveFormatConversionStream.CreatePcmStream(reader))
                    {
                        WaveFileWriter.CreateWaveFile(outputFileName, waveStream);
                    }
                }

                //Re-encode the stream with a mono channel, 16bits and 16kHz
                using (WaveStream readWaveStream = new WaveFileReader(outputFileName))
                {
                    WaveFormat target = new WaveFormat(16000, 16, 1);

                    WaveFormatConversionStream monoStream = new WaveFormatConversionStream(target, readWaveStream);
                    WaveFileWriter.CreateWaveFile(pcmFilename, monoStream);

                }             
                    }

I don't know if the licensing of Naudio would allow me to do this. I have to check.

Thanks a lot,

Omid.


New Post: Windows 8 WinRT Metro Style Support

$
0
0

I'd love to make a WinRT version of NAudio, but as you have discovered, NAudio contains wrappers for lots of APIs that are disallowed in WinRT (I assume this will include all waveIn, waveOut, and acm functions). I'm hoping to experiment with Windows 8 and see what is possible in the near future. There are some new Audio APIs that are part of WinRT, which I presume Windows Store applications are supposed to use exclusively.

New Post: Windows 8 WinRT Metro Style Support

$
0
0

Sure I understand. Thanks anyway.

Omid.

Source code checked in, #d6964d7e51df

$
0
0
making more properties visible on Mp3Frame, and Mp3FileReader now allows pluggable MP3 frame decompressor

Source code checked in, #f9484b8a8c31

$
0
0
updating for new NuGet prerelease

New Post: API for Position Reporting

$
0
0

Mark,

I'm working on a position reporting patch for NAudio's wave player classes (and maybe the wave in stuff).  Do you want that functionality split to a separate interface (IWavePosition), or added to the existing IWavePlayer (and maybe IWaveIn) interfaces?

This API is basically so timestamps can be calculated to within a small margin of error.  This should be useful for anyone doing "sync" with the audio stream.  I'll use it for visualizations and a playback clock... :)

New Post: AcmStreamHeader dispose was not called

$
0
0

Hi,

I get an exception when play sound by NAudio's WaveOut

Like:

 

AcmStreamHeader dispose was not called

     at AcmStreamHeader.Finalized()

    H:\test\naudio_source\NAudio\Wave\Compression\AcmStreamHeader.cs(117)

 

Thank you !!

New Post: Convert wav to ulaw wav??

$
0
0

I want to take a wave file (in this example it is 1,536 Kbps, 48 KHz, 16 bit, 2 channel, PCM) and convert it to a wave file that is 64 Kbps, 8,000 Hz, 8 bits, 1 channel, ADPCM(CCITT) (U-Law).

My current code is:

	    openFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Wave Files (*.wav)|*.wav|All Files (*.*)|*.*";
            openFileDialog.FilterIndex = 1;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                fileName = openFileDialog.FileName;
            }

            WaveStream mainStream = new WaveFileReader(fileName);

            WaveFormat target = WaveFormat.CreateMuLawFormat(8000, 1);

            WaveFormatConversionStream str = new WaveFormatConversionStream(target, mainStream);

            try
            {
                WaveFileWriter.CreateWaveFile(@"C:\Users\joshua\Desktop\test.wav", str);
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("{0}", ex.Message));
            }
            finally
            {
                str.Close();
            }
                
            MessageBox.Show("File conversion complete!");
        }

If I do a standard format with WaveFormat test = new WaveFormat(8000, 8, 1); I get what I want but it is in PCM format and not U-Law.  How can I get it to be in U-Law format?


New Post: Visual Studio 2012 express - NAudio Components don't show in toolbox

$
0
0

Hi Guys,

Maybe you can help me out here, I have added the naudio.dll as a reference to a new C# project using Visual Studio 2012 express for desktop.

But the visual Components do not show up in my toolbox.

Screenshot

 

http://janpeter.net/naudio.jpg

What am I missing to get the visual components to work?

(Yes, I am new to C#, this is only my second project and the first time I am trying to use third party components - so it might be totally easy to fix, and no naudio problem at all.)

Any help is very much appreciated.

Good night,

JP

New Post: Convert wav to ulaw wav??

$
0
0

you need to go in two steps (two waveformatconversionstreams). First go to mono 8kHz 16bit, then go to mulaw

Mark

New Post: WaveFloatTo16Provider class: Only PCM supported

$
0
0

This is my first project involved with NAudio... In the WaveFloatTo16Provider class, should the "PCM" in this "Only PCM supported" message be "IeeeFloat" instead?

New Post: Visual Studio 2012 express - NAudio Components don't show in toolbox

$
0
0

Ok, so it was indeed a newbie c# problem. - Just incase someone googles this thread, here is how to get the components into the toolbox:

1) right click into the toolbox

2) click "Choose items"

3) in the now visible "Choose Toolbox Items"-dialog click on "browse"

4) navigate to the naudio.dll and select it

et violà the controls are now available.

New Post: Newbie: Kinect service ==>Byte array to speaker

$
0
0

Hi,

I am a newbie and  so my knoweldge on sur the language (english and C#) are not perferct, that why i need lot of explanation.


Here is the problem:
I used the kinet service with success for transmitte the video between two PC on the network (WPF application with visual studio 2010).

For  audio, the server (pc where is plug the kinect) transmit byte array of sound data over the  network.

On the client side there is a event called "Audio frame ready" and really don't know what to put in there for make it working.

I tried different code found over the discussion in Naudio with no success

Here is the code in the client side:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using NetComm;
using Coding4Fun.Kinect.KinectService.Common;
using Coding4Fun.Kinect.KinectService.WpfClient;
using System.IO;
using NAudio.Wave;
using NAudio.CoreAudioApi;
using System.Threading;
using System.Media;


namespace clientcommres
{
    /// <summary>
    /// Logique d'interaction pour MainWindow.xaml
    /// </summary>
    /// 
    public partial class MainWindow : Window
    {

        WaveFormat toto;
        MemoryStream memoryStream;
        
        string ConvertBytesToString(byte[] bytes)
        {
            return ASCIIEncoding.ASCII.GetString(bytes);
        }

        byte[] ConvertStringToBytes(string str)
        {
            return ASCIIEncoding.ASCII.GetBytes(str);
        }

         SoundPlayer myPlayer = new SoundPlayer("myFile.wav");
        FileStream fs = File.Create("myfile.wav");
        
        NetComm.Client client = new NetComm.Client();


        public MainWindow()
        {
            InitializeComponent();


            client.Connected += new Client.ConnectedEventHandler(client_Connected);
            client.Disconnected += new Client.DisconnectedEventHandler(client_Disconnected);
            client.DataReceived += new Client.DataReceivedEventHandler(client_DataReceived);
           
            toto =new WaveFormat(16000,4);
            
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
           

          
           //connect to the host 
            client.Connect("192.168.0.23",2200, "Jack");
            ColorClient colorClient = new ColorClient();
            Coding4Fun.Kinect.KinectService.WpfClient.AudioClient audioClient = new Coding4Fun.Kinect.KinectService.WpfClient.AudioClient();

            colorClient.ColorFrameReady += clientColorFrameReady;
            audioClient.AudioFrameReady += audioClient_AudioFrameReady;
            colorClient.Connect("192.168.0.23", 4530);
            audioClient.Connect("192.168.0.23", 4533);
           
        }

        void audioClient_AudioFrameReady(object sender, AudioFrameReadyEventArgs e)
        {


            memoryStream = new MemoryStream(e.AudioFrame.AudioData);

            //memoryStream.Position = 0;
            RawSourceWaveStream waveStream = new RawSourceWaveStream(memoryStream, toto);
            WaveStream conversionStream = WaveFormatConversionStream.CreatePcmStream(waveStream);
            using (WaveStream blockAlignedStream = new BlockAlignReductionStream(conversionStream))
            {
                using (WaveOut waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()))
                {
                    WaveChannel32 activestream = new WaveChannel32(blockAlignedStream);
                    waveOut.Init(activestream);
                    waveOut.Play();
                    while (waveOut.PlaybackState == PlaybackState.Playing)
                    {
                        System.Threading.Thread.Sleep(100);
                    }
                }


            }
        }



        void clientColorFrameReady(object sender, ColorFrameReadyEventArgs e)
        {
            // Video is a WPF or Windows Phone Image control
            image1.Source = e.ColorFrame.BitmapImage;
        }

        void client_Connected()
        {
            Log.AppendText("Connected successfully!" +
            Environment.NewLine); //Updates the log with the current connection state
        }

        void client_Disconnected()
        {
            Log.AppendText("Disconnected from host!" +
            Environment.NewLine); //Updates the log with the current connection state
        }

        void client_DataReceived(byte[] Data, string ID)
        {
            Log.AppendText(ID + ": " + ConvertBytesToString(Data) + Environment.NewLine); //Updates the log with the current connection state
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            client.SendData(ConvertStringToBytes(ChatMessage.Text));
        }

        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (client.isConnected) client.Disconnect(); //Disconnects if the 
            //client is connected, closing the communication thread
        }
        
       
    }
}

 

 

 

Viewing all 5831 articles
Browse latest View live


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