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

New Post: PianoRoll

$
0
0
Code behind part 2:
private void HolderCanvas_MouseWheel(object sender, MouseWheelEventArgs e)
    {
        int NoMeasures = (GridDisplayWidth / DeltaTicks) / 4;
        ScaleFactorX = Math.Min(Math.Max(ScaleFactorX + (e.Delta / 2000), 1), NoMeasures / 2);

        ScalePianoRoll();

    }
    Path SelectedNotePath;
    NoteOnEvent SelectedNote;
    double CursorY;
    double CursorX;
    bool MouseDownOnNote;
    RectangleGeometry SelRectGeom;
    double SelRectTop;
    double SelRectLeft;
    public event NotesChangedEventHandler NotesChanged;
    public delegate void NotesChangedEventHandler();
    private void MouseUpInNote(object sender, MouseButtonEventArgs e)
    {
        MouseDownOnNote = false;
        SelectedNotePath.ReleaseMouseCapture();
        if (NotesChanged != null) {
            NotesChanged();
        }
    }
    private bool GetNoteFromGeom(MidiEvent midev)
    {

        bool IsNote = false;
        if (midev.GetType == typeof(NoteOnEvent)) {
            NoteOnEvent midnoteonev = (NoteOnEvent)midev;
            IsNote = (SelRectGeom.Rect.Left == (midnoteonev.AbsoluteTime * xScale)) & (SelRectGeom.Rect.Top == ((127 - midnoteonev.NoteNumber) * yScale + 1));
            //IsNote = IsNote And SelRectGeom.Rect.Width = midnoteonev.NoteLength * xScale     'not necessary - enough to just get the x and y locations
        }

        return IsNote;

    }

    private void MouseDownInNote(object sender, MouseButtonEventArgs e)
    {
        MouseDownOnNote = true;
        CursorY = e.GetPosition(sender).Y;
        CursorX = e.GetPosition(sender).X;

        SelectedNotePath = (Path)sender;
        SelRectGeom = SelectedNotePath.Data;
        SelRectTop = SelRectGeom.Rect.Y;
        SelRectLeft = SelRectGeom.Rect.X;
        SelectedNote = MidiEvents.Find(GetNoteFromGeom);

        SelectedNotePath.CaptureMouse();

        Canvas.SetZIndex(SelectedNotePath, NoteCanvas.Children.Count);
        //show this note above all other notes

    }

    private void MouseMoveNote(object sender, MouseEventArgs e)
    {
        if (MouseDownOnNote) {
            //Snap mouse y position to nearest note and limit to between 0-127
            SelectedNote.NoteNumber = Math.Min(Math.Max(127 - Conversion.Int((SelRectTop + e.GetPosition(sender).Y - CursorY) / yScale), 0), 127);

            int NewPos = SelRectLeft / xScale + (e.GetPosition(sender).X - CursorX) / (xScale * ScaleFactorX);
            //Get the nearest snap position and limit to within max/min range
            int SnapPosition = Math.Min(Math.Max(0, (NewPos - Conversion.Int(NewPos % NoteSnapTo))), lastPosition - Conversion.Int(lastPosition % NoteSnapTo));

            int prevselnotetime = SelectedNote.AbsoluteTime;
            SelectedNote.AbsoluteTime = SnapPosition;
            SelectedNote.OffEvent.AbsoluteTime += (SelectedNote.AbsoluteTime - prevselnotetime);

            SelRectGeom.Rect = new Rect(Convert.ToDouble(SelectedNote.AbsoluteTime) * xScale, Convert.ToDouble(127 - SelectedNote.NoteNumber) * yScale + 1, Convert.ToDouble(SelectedNote.NoteLength) * xScale, (yScale - 1));

        }

        //Scroll with mouse drag
        if (e.GetPosition(UDScrollViewer).Y < 0) {
            UDScrollViewer.ScrollToVerticalOffset(UDScrollViewer.VerticalOffset - 0.1);
        }
        if (e.GetPosition(UDScrollViewer).Y > UDScrollViewer.ActualHeight) {
            UDScrollViewer.ScrollToVerticalOffset(UDScrollViewer.VerticalOffset + 0.1);
        }
        if (e.GetPosition(RLScrollViewer).X < 0) {
            RLScrollBar.Value -= 0.001;
        }
        if (e.GetPosition(RLScrollViewer).X > RLScrollViewer.ActualWidth) {
            RLScrollBar.Value += 0.001;
        }

    }
    private void MouseEnterNote(object sender, MouseEventArgs e)
    {
        dynamic thisNotePath = (Path)sender;
        thisNotePath.Fill = SelectedNoteBrush;
    }

    private void MouseLeaveNote(object sender, MouseEventArgs e)
    {
        dynamic thisNotePath = (Path)sender;
        thisNotePath.Fill = NoteBrush;
    }
    int NoteSnapTo = 1;

    private void SnapToCB_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        switch (SnapToCB.SelectedValue.ToString) {
            case "Snap":
                NoteSnapTo = 1;
                break;
            case "1/2 note":
                NoteSnapTo = DeltaTicks * 2;
                break;
            case "1/4 note":
                NoteSnapTo = DeltaTicks;
                break;
            case "1/8 note":
                NoteSnapTo = DeltaTicks / 2;
                break;
            case "1/16 note":
                NoteSnapTo = DeltaTicks / 4;
                break;
        }

    }


}

New Post: PianoRoll

New Post: PianoRoll

$
0
0
Incidentally, the MidiEventsDP and DeltaTicksDP are set as dependency properties to allow binding to other controls depending on how the PianoRoll will be implemented. If it's not to have binding with anything, the dependency properties could be changed to simple Properties.

New Post: two problems with wave playack

$
0
0
I changed file playback to memory stream playback and now knock at the beginning and at the end of playback do not occur.

Created Unassigned: naudio doesn't support Logitech audio drivers? [16505]

$
0
0
I recently purchased a Logitech Gaming headset that works fine in all applications and games, except a game that is using the NAudio functions. At any point in the game where sound appears to be processed by the NAudio dll, the game crashes. I contacted the developer and after looking at the error logs they stated that NAudio doesn't support the Logitech audio drivers.

Below is an excerpt from the log file:

[12/24/2016 6:02:05 PM.820] SirenMastery: at NAudio.Wave.WaveOutEvent.Init(IWaveProvider waveProvider)
[12/24/2016 6:02:05 PM.820] at ?????????????????????????????????????????.????????????????????????????????????????.?????????????????????????????????????????(WaveChannel32 , ????????????????????????????????????????? , Boolean )
[12/24/2016 6:02:05 PM.820] at ?????????????????????????????????????????.?????????????????????????????????????????.?????????????????????????????????????????(Model )
[12/24/2016 6:02:05 PM.820] at ?????????????????????????????????????????.?????????????????????????????????????????.?????????????????????????????????????????.?????????????????????????????????????????()
[12/24/2016 6:02:05 PM.820] at Rage.GameFiber.Main()

Released: NAudio 1.8 (Dec 27, 2016)

$
0
0
  • Windows 10 Universal project. Very similar feature set to the Win 8 one.
* Added a Windows 10 Universal demo app with limited functionality
  • Windows 10 related bugfixes
* WasapiOut fixed for Win 10
  • WaveFileWriterRT for Win 8/10 (thanks to kamenlitchev)
  • Improvements to Mp3FileReader seeking and position reporting (thanks to protyposis)
  • updated NAudio build process to use FAKE, retiring the old MSBuild and IronPython scripts
  • NAudio.Wma project is moved out into its own GitHub repository(https://github.com/naudio/NAudio.Wma)
  • ConcatenatingSampleProvider and FollowedBy extension method making it easy to concatenate Sample Providers
  • MixingSampleProvider raises events as inputs are removed and allows access to list of inputs
  • Improvements to MIDI event classes including clone support (thanks to Joseph Musser)
  • SMBPitchShiftingSampleProvider (thanks to Freefall63)
  • StreamMediaFoundationReader to allow using MediaFoundation with streams
  • New Skip, ToMono, Take, ToStereo extension methods
  • New SilenceProvider class
  • OffsetSampleProvider fix for leadout following take
  • Various bugfixes and enhancements. See commit log for full details
* WasapiCapture buffer sizes can be specified
* MMDeviceEnumerator is disposable
* MidiMessage better error reporting
* More robust AIFF file handling
* Fixed threading issue on WasapiCaptureRT
* WasapiCaptureRT returns regular IEEE WaveFormat instead of WaveFormatExtensible
* RawSourceWaveStream allows you to read from part of input array
* RawSourceStream handles end of stream better
* PropVariant supports VT_BOOL
* Better handling of exceptions in WaveFileReader constructor
* WasapiOut default constructor (uses default device, shared mode)
* WasapiCapture and WasapiLoopbackCapture can report capture state
* BufferedWaveProvider can be configured to not fully read if no data is available
* WasapiOut can report the default mix format for shared mode
* AsioDriver and AsioDriver ext now public
* Fix for Xing header writing
* Fixed XING header creation bug
* Fixed MIDI to type 1 converter bug

Created Release: NAudio 1.8 (Dec 27, 2016)

$
0
0
  • Windows 10 Universal project. Very similar feature set to the Win 8 one.
* Added a Windows 10 Universal demo app with limited functionality
  • Windows 10 related bugfixes
* WasapiOut fixed for Win 10
  • WaveFileWriterRT for Win 8/10 (thanks to kamenlitchev)
  • Improvements to Mp3FileReader seeking and position reporting (thanks to protyposis)
  • updated NAudio build process to use FAKE, retiring the old MSBuild and IronPython scripts
  • NAudio.Wma project is moved out into its own GitHub repository(https://github.com/naudio/NAudio.Wma)
  • ConcatenatingSampleProvider and FollowedBy extension method making it easy to concatenate Sample Providers
  • MixingSampleProvider raises events as inputs are removed and allows access to list of inputs
  • Improvements to MIDI event classes including clone support (thanks to Joseph Musser)
  • SMBPitchShiftingSampleProvider (thanks to Freefall63)
  • StreamMediaFoundationReader to allow using MediaFoundation with streams
  • New Skip, ToMono, Take, ToStereo extension methods
  • New SilenceProvider class
  • OffsetSampleProvider fix for leadout following take
  • Various bugfixes and enhancements. See commit log for full details
* WasapiCapture buffer sizes can be specified
* MMDeviceEnumerator is disposable
* MidiMessage better error reporting
* More robust AIFF file handling
* Fixed threading issue on WasapiCaptureRT
* WasapiCaptureRT returns regular IEEE WaveFormat instead of WaveFormatExtensible
* RawSourceWaveStream allows you to read from part of input array
* RawSourceStream handles end of stream better
* PropVariant supports VT_BOOL
* Better handling of exceptions in WaveFileReader constructor
* WasapiOut default constructor (uses default device, shared mode)
* WasapiCapture and WasapiLoopbackCapture can report capture state
* BufferedWaveProvider can be configured to not fully read if no data is available
* WasapiOut can report the default mix format for shared mode
* AsioDriver and AsioDriver ext now public
* Fix for Xing header writing
* Fixed XING header creation bug
* Fixed MIDI to type 1 converter bug

Commented Unassigned: naudio doesn't support Logitech audio drivers? [16505]

$
0
0
I recently purchased a Logitech Gaming headset that works fine in all applications and games, except a game that is using the NAudio functions. At any point in the game where sound appears to be processed by the NAudio dll, the game crashes. I contacted the developer and after looking at the error logs they stated that NAudio doesn't support the Logitech audio drivers.

Below is an excerpt from the log file:

[12/24/2016 6:02:05 PM.820] SirenMastery: at NAudio.Wave.WaveOutEvent.Init(IWaveProvider waveProvider)
[12/24/2016 6:02:05 PM.820] at ?????????????????????????????????????????.????????????????????????????????????????.?????????????????????????????????????????(WaveChannel32 , ????????????????????????????????????????? , Boolean )
[12/24/2016 6:02:05 PM.820] at ?????????????????????????????????????????.?????????????????????????????????????????.?????????????????????????????????????????(Model )
[12/24/2016 6:02:05 PM.820] at ?????????????????????????????????????????.?????????????????????????????????????????.?????????????????????????????????????????.?????????????????????????????????????????()
[12/24/2016 6:02:05 PM.820] at Rage.GameFiber.Main()
Comments: I am not aware of any Logitech related issues. Have you got the latest soundcard drivers? Without seeing more of the code I don't know what the issue is. Could be that they are trying to initialize the soundcard with an unsupported WaveFormat.

Commented Unassigned: naudio doesn't support Logitech audio drivers? [16505]

$
0
0
I recently purchased a Logitech Gaming headset that works fine in all applications and games, except a game that is using the NAudio functions. At any point in the game where sound appears to be processed by the NAudio dll, the game crashes. I contacted the developer and after looking at the error logs they stated that NAudio doesn't support the Logitech audio drivers.

Below is an excerpt from the log file:

[12/24/2016 6:02:05 PM.820] SirenMastery: at NAudio.Wave.WaveOutEvent.Init(IWaveProvider waveProvider)
[12/24/2016 6:02:05 PM.820] at ?????????????????????????????????????????.????????????????????????????????????????.?????????????????????????????????????????(WaveChannel32 , ????????????????????????????????????????? , Boolean )
[12/24/2016 6:02:05 PM.820] at ?????????????????????????????????????????.?????????????????????????????????????????.?????????????????????????????????????????(Model )
[12/24/2016 6:02:05 PM.820] at ?????????????????????????????????????????.?????????????????????????????????????????.?????????????????????????????????????????.?????????????????????????????????????????()
[12/24/2016 6:02:05 PM.820] at Rage.GameFiber.Main()
Comments: Yes, the latest drivers were downloaded from Logitech. It appears that the issue occurs when using the Logitech Gaming Software which enables the surround sound for the headset via either Dolby or DTX. If that software is removed from the system, the game functions although all surround sound functions are lost. I did read on Logitech's website that Microsoft was requiring mfg's to use the "ABO drivers" to support surround sound and to not rely on the Microsoft OS for providing that function.

Reviewed: NAudio 1.8 (Dez 27, 2016)

$
0
0
Rated 5 Stars (out of 5) - Finally some major improvements found its way into NAudio!

Commented Unassigned: naudio doesn't support Logitech audio drivers? [16505]

$
0
0
I recently purchased a Logitech Gaming headset that works fine in all applications and games, except a game that is using the NAudio functions. At any point in the game where sound appears to be processed by the NAudio dll, the game crashes. I contacted the developer and after looking at the error logs they stated that NAudio doesn't support the Logitech audio drivers.

Below is an excerpt from the log file:

[12/24/2016 6:02:05 PM.820] SirenMastery: at NAudio.Wave.WaveOutEvent.Init(IWaveProvider waveProvider)
[12/24/2016 6:02:05 PM.820] at ?????????????????????????????????????????.????????????????????????????????????????.?????????????????????????????????????????(WaveChannel32 , ????????????????????????????????????????? , Boolean )
[12/24/2016 6:02:05 PM.820] at ?????????????????????????????????????????.?????????????????????????????????????????.?????????????????????????????????????????(Model )
[12/24/2016 6:02:05 PM.820] at ?????????????????????????????????????????.?????????????????????????????????????????.?????????????????????????????????????????.?????????????????????????????????????????()
[12/24/2016 6:02:05 PM.820] at Rage.GameFiber.Main()
Comments: you can usually only play stereo audio with WaveOut drivers, so I suspect this is the reason.

New Post: Audacity pan

$
0
0
in audacity there a pan you can put it all the right to the right speaker or to the left speaker...
how do I do that with Naudio ?

I tried
waveout = new WaveOut();
        WaveChannel32 temp = new WaveChannel32(BBeats);
        temp.PadWithZeroes = false;
        temp.Pan = 100;
        waveout.Init(temp);
        waveout.Play();

but it did not work

in Audacity you can set pan to only play from the right or the left speaker..
how can i do that in Naudio ?

New Post: Right ear is still playing

New Post: naudio soundfont to waveout play

$
0
0
can you give a sample of soundfont
NAudio.SoundFont.SoundFont pianoroll = new NAudio.SoundFont.SoundFont("organ.sf2");
i started with it.
please help this subject
how to convert WaveProvider

New Post: Recording does not start while there is no audio signal

$
0
0
I'm trying to record audio from the microfone and the speaker output simultaneously:
micInputAudioSource = new WasapiCapture(micDevice);
micInputAudioWriter = CreateMp3Writer(micInputFileName, micInputAudioSource.WaveFormat, mp3AudioQualityPreset);
micInputAudioSource.DataAvailable += OnMicInputAudioDataAvailable;

outputAudioSource = new WasapiLoopbackCapture(outDevice);
outputAudioWriter = CreateMp3Writer(outputFileName, outputAudioSource.WaveFormat, mp3AudioQualityPreset);
outputAudioSource.DataAvailable += OnOutputAudioDataAvailable;

micInputAudioSource.StartRecording();
outputAudioSource.StartRecording();
This works perfectly except that the outputAudioSource only starts recording when there is an actual audio signal. If there is silence, the output file does not contain any data. In this case, the DataAvailable event will be triggered repeatedly but the WaveInEventArgs.BytesRecorded property contains 0, so no samples are written. This is a problem because I need to synchronize both audio signals.

How can I start the recording immediately, even if there is only silence to record?
Or, if this is not possible, how can I synchronize both audio streams to mix them at the exact time?

New Post: How to mix audio signals during recording?

$
0
0
How can I mix two different audio signals and write the ouput into one stream during recording? Currently, I record two signals from different devices and write them in two seperate files. After ending the recording, I mix the two files using a WaveMixerStream32:
// Loading first MP3 file
using (var fileReader1 = new Mp3FileReader(intputFile1))
{
    // Converting into 32 floating point format for mixing
    using (WaveStream convertedStream1 = new WaveChannel32(fileReader1))
    {
        // Loading second file
        using (var fileReader2 = new Mp3FileReader(intputFile2))
        {
            using (WaveStream convertedStream2 = new WaveChannel32(fileReader2))
            {
                // Mixing both streams
                using (var mixer = new WaveMixerStream32())
                {
                    mixer.AddInputStream(convertedStream1);
                    mixer.AddInputStream(convertedStream2);

                    // Converting back to integer sample format
                    using (WaveStream intOutput = new Wave32To16Stream(mixer))
                    {
                        // Converting into user-defined output format
                        using (WaveStream convertedOutput = new WaveFormatConversionStream(OutputWaveFormat, intOutput))
                        {
                            // Writing to output file
                            using (LameMP3FileWriter outputWriter = new LameMP3FileWriter(outputFile, convertedOutput.WaveFormat, mp3AudioQualityPreset))
                            {
                                convertedOutput.CopyTo(outputWriter);
                            }
                        }
                    }
                }
            }
        }
    }
}
But I need to mix both audio signals on-the-fly to process the mixed-down stream in realtime during the recording. I figured that I need to use a BufferedWaveProvider but I don't understand how this could be achived. Is there an example that shows how to use the BufferedWaveProvider for this purpose? Or is there another way to achive this by using NAudio?

New Post: What is the difference between WaveFileWriter.Dispose() and LameMP3FileWriter.Dispose()

$
0
0
Is there a reason that the WaveFileWriter.Dispose method closes the underlying stream, but the LameMP3FileWriter.Dispose method does not?

That seems to make it hard to handle both file types the same way.

New Post: Change Speaker Configuration and Sample Rate of a Playback device programmatically

$
0
0
With a few clicks of a mouse I can change the 'Speaker Configuration' to 5.1 and the sample rate to 24bit 48000hz. You see on my machine, every once in a while it is being reset because of another unrelated issue. I want to programmatically set it back. I can't seem to find in the documentation how to do this. I think it would be in NAudio.CoreAudioApi.
I'm using C#.

New Post: Audiometer in Asio input

$
0
0
Hello
in my callback procedure for a the asio input I can not use the audiometer. there will be a com exception message that this function is not supported. I used the code from asio example:

I used for test explicitlly values for recordChannelCount and NAudio.Wave.AsioOut
               //int recordChannelCount = GetUserSpecifiedChannelCount();
                int recordChannelCount = 1;

                // create device if necessary
                if (this.asioOut == null)
                {
                    //this.asioOut = new NAudio.Wave.AsioOut(comboBoxAsioDevice.Text); 
                    this.asioOut = new NAudio.Wave.AsioOut(0);

                    //this.asioOut.InputChannelOffset = GetUserSpecifiedChannelOffset();
                    this.asioOut.InputChannelOffset = 1;
                    this.asioOut.InitRecordAndPlayback(null, recordChannelCount, 44100);
                    this.asioOut.AudioAvailable += asioOut_AudioAvailable;
                }

                this.fileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".wav");
                this.writer = new WaveFileWriter(fileName, new WaveFormat(44100, recordChannelCount));
                this.asioOut.Play();
                this.timer1.Enabled = true;

and the callback function:


void asioOut_AudioAvailable(object sender, AsioAudioAvailableEventArgs e)
        {
            var samples = e.GetAsInterleavedSamples();
            writer.WriteSamples(samples, 0, samples.Length);


            // bwp.AddSamples(e.Buffer, 0, e.BytesRecorded);
            double duckWert = (double)Convert.ToDouble(globalRightVolume) * (double)((double)Convert.ToInt32(Program.myRemoteArranger.myConfigVerwaltung.duckReduktion) / 100);
            var device = (NAudio.CoreAudioApi.MMDevice)Program.myRemoteArranger.myConfigVerwaltung.comboBox1.SelectedItem;
            //int wert = (int)(Math.Round(device.AudioMeterInformation.MasterPeakValue * 1000));
            int wert = (int)(Math.Round(device.AudioMeterInformation.MasterPeakValue * 2000));
//.........
}
the callback procedure crashes at the last line with:
_Das COM-Objekt des Typs "System._ComObject" kann nicht in den Schnittstellentyp "NAudio.CoreAudioApi.Interfaces.IMMDevice" umgewandelt werden. Dieser Vorgang konnte nicht durchgeführt werden, da der QueryInterface-Aufruf an die COM-Komponente für die Schnittstelle mit der IID "{D666063F-1587-4E43-81F1-B948E807363F}" aufgrund des folgenden Fehlers nicht durchgeführt werden konnte: Schnittstelle nicht unterstützt (Ausnahme von HRESULT: 0x80004002 (E_NOINTERFACE)).

Could someone help me? Thank you very much.
Thom

Created Unassigned: Audiobook length > 24 hours Playing issue [16506]

$
0
0
If an audiobook (m4b) file is longer than 24 hours in length and the AudioFileReader.Position is set anywhere past the 24 hour mark, AudioFileReader.Play will produce the error: __"Not a legal OleAut date"__ and the file won't play.

Note that the file will successfully play through and beyond the 24 hour mark while playing continuously. However, attempting to set the Position greater than 24 hours and then playing will cause the above mentioned error to occur.

This also occurs after setting the AudioFileReader.CurrentTime to a Timespan > 24 hours (1 day or greater).

Unfortunately, this makes the NAudio component unusable for an audiobook application. :(
Viewing all 5831 articles
Browse latest View live


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