Jan 30 at 9:44 PM
Edited Jan 30 at 9:44 PM
|
Hello Mark Heath.
First I want to thank you and your helpers for this great Sound Lib. You probably made the only full .NET Sound lib with that many functions :) Well, I have to come to my question now:
I set the NAudio.dll reference, set up the imports and declared a new NAudio.Wave.WaveOut
object. Then I init the ogg stream to it and start the playback. How can I implement A FFT Spectrum of the stream now, which winforms element should I use to Display that? I saw you support that in the dsp class. Any short usage example would be great. Full Code:
Imports NVorbis
Imports NAudio
Public Class Form1
Dim stream As System.IO.UnmanagedMemoryStream
Dim waveOut = New NAudio.Wave.WaveOut()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
stream = My.Resources.Test1 '// This is a ogg file, it is only named as Wave file to get a stream ;)
Dim OggStreamReader = New NVorbis.NAudioSupport.VorbisWaveReader(stream)
waveOut.Init(OggStreamReader)
waveOut.play()
End Sub
End Class
You can download the full Project from my public ftp here if you want to take a look into the full Project: ftp://www.untergrund.net/users/Freefall/News%20Section/NVorbis%26NAudioTest.rar
|
|
Coordinator
Jan 31 at 6:04 AM
|
Hi, I explain how to use FFT in NAudio in this article. Be warned that it if you are new to audio DSP, it can take a while to understand how to use FFT. If you want to visualise the FFT with a spectrum analyser, there is a great NAudio example in this project.
|
|
|
|
Thanks for your quick reply. Well, it seems wpfsvl is a good way to go, but I have 2 problems now:
1) Wpfsvl needs .Net Framework 4.0 and I don´t want to have to install it on my computers.
2) There is a example project showing the usage of NAudio with it, but source code or guides for the compiled NAudio example are not provided :-Y . That makes me angry, it wouldn´t be that much work to include the example project source code ...
=> So this seems to be a dead end. Could you please release an example of using FFT with NAudio? Would be fantastic!! I would be your biggest fan then :) It should only show the basic functions, I don´t need a full example. I don´t want to steal your spare time you know :)
|
|
Coordinator
Jan 31 at 3:20 PM
|
1) I don't see why wpfsvl needs .NET 4.0. You should be able to recompile it to .NET 3.5.
2) The code is available here
My example of how to use FFT with NAudio is the one in the article I linked above.
For another, perhaps simpler example, look at the WPFDemo that comes with NAudio. It contains a class called SampleAggregator which is calculating the FFTs, and SpectrumAnalyser draws them (but it doesn't look nearly as good as the one in wpfsvl)
Mark
|
|
|
|
Ok, so if I try to compile with .NET Framework 3.5 I get various errors listed:
Fehler 1 "System.Windows.Controls.Canvas" enthält keine Definition für "CacheMode", und es konnte keine Erweiterungsmethode "CacheMode" gefunden werden, die ein erstes Argument vom Typ "System.Windows.Controls.Canvas" akzeptiert. (Fehlt eine Using-Direktive oder ein Assemblyverweis?) C:\Users\Freefall\Desktop\WFPSVL\WPFSVL\Source\WPFSoundVisualizationLibrary\WaveForm Timeline\WaveformTimeline.cs 714 28 WPFSoundVisualizationLib
Fehler 2 Der Typ- oder Namespacename "BitmapCache" konnte nicht gefunden werden. (Fehlt eine Using-Direktive oder ein Assemblyverweis?) C:\Users\Freefall\Desktop\WFPSVL\WPFSVL\Source\WPFSoundVisualizationLibrary\WaveForm Timeline\WaveformTimeline.cs 714 44 WPFSoundVisualizationLib
Fehler 3 Der Typ- oder Namespacename "BitmapCache" konnte nicht gefunden werden. (Fehlt eine Using-Direktive oder ein Assemblyverweis?) C:\Users\Freefall\Desktop\WFPSVL\WPFSVL\Source\WPFSoundVisualizationLibrary\WaveForm Timeline\WaveformTimeline.cs 920 13 WPFSoundVisualizationLib
Fehler 4 Der Typ- oder Namespacename "BitmapCache" konnte nicht gefunden werden. (Fehlt eine Using-Direktive oder ein Assemblyverweis?) C:\Users\Freefall\Desktop\WFPSVL\WPFSVL\Source\WPFSoundVisualizationLibrary\WaveForm Timeline\WaveformTimeline.cs 920 42 WPFSoundVisualizationLib
Fehler 5 "System.Windows.Controls.Canvas" enthält keine Definition für "CacheMode", und es konnte keine Erweiterungsmethode "CacheMode" gefunden werden, die ein erstes Argument vom Typ "System.Windows.Controls.Canvas" akzeptiert. (Fehlt eine Using-Direktive oder ein Assemblyverweis?) C:\Users\Freefall\Desktop\WFPSVL\WPFSVL\Source\WPFSoundVisualizationLibrary\WaveForm Timeline\WaveformTimeline.cs 920 69 WPFSoundVisualizationLib
It seems that "CacheMode" is not a member of "System.Windows.Controls.Canvas". I don´t need to reference that taglib-sharp.dll, right? Any suggestions?
|
|
Coordinator
Jan 31 at 3:59 PM
|
it's a new property in .NET 4 to help optimise drawing. Just delete any lines of code that set it.
|
|
Jan 31 at 4:13 PM
Edited Jan 31 at 4:15 PM
|
Ok good. All errors resolved an I compiled with .Net Framework 3.5. SO far so good. But the example project still shows "some" error messages:
Fehler 1 Der Name "InitializeComponent" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 19 13 Sample_NAudio
Fehler 2 Der Name "StopButton" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 24 51 Sample_NAudio
Fehler 3 Der Name "PlayButton" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 25 51 Sample_NAudio
Fehler 4 Der Name "PauseButton" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 26 52 Sample_NAudio
Fehler 5 Der Name "repeatStartTimeEdit" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 27 58 Sample_NAudio
Fehler 6 Der Name "repeatStopTimeEdit" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 28 56 Sample_NAudio
Fehler 7 Der Name "spectrumAnalyzer" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 30 13 Sample_NAudio
Fehler 8 Der Name "waveformTimeline" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 31 13 Sample_NAudio
Fehler 9 Der Name "albumArtPanel" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 57 37 Sample_NAudio
Fehler 10 Der Name "albumArtPanel" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 61 37 Sample_NAudio
Fehler 11 Der Name "albumArtPanel" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 70 29 Sample_NAudio
Fehler 12 Der Name "albumArtPanel" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 75 25 Sample_NAudio
Fehler 13 Der Name "clockDisplay" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 79 21 Sample_NAudio
Fehler 14 Der Name "DefaultThemeMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 114 13 Sample_NAudio
Fehler 15 Der Name "DefaultThemeMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 115 13 Sample_NAudio
Fehler 16 Der Name "ExpressionDarkMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 116 13 Sample_NAudio
Fehler 17 Der Name "ExpressionDarkMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 117 13 Sample_NAudio
Fehler 18 Der Name "ExpressionLightMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 118 13 Sample_NAudio
Fehler 19 Der Name "ExpressionLightMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 119 13 Sample_NAudio
Fehler 20 Der Name "DefaultThemeMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 126 13 Sample_NAudio
Fehler 21 Der Name "DefaultThemeMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 127 13 Sample_NAudio
Fehler 22 Der Name "ExpressionDarkMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 128 13 Sample_NAudio
Fehler 23 Der Name "ExpressionDarkMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 129 13 Sample_NAudio
Fehler 24 Der Name "ExpressionLightMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 130 13 Sample_NAudio
Fehler 25 Der Name "ExpressionLightMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 131 13 Sample_NAudio
Fehler 26 Der Name "DefaultThemeMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 140 13 Sample_NAudio
Fehler 27 Der Name "DefaultThemeMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 141 13 Sample_NAudio
Fehler 28 Der Name "ExpressionDarkMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 142 13 Sample_NAudio
Fehler 29 Der Name "ExpressionDarkMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 143 13 Sample_NAudio
Fehler 30 Der Name "ExpressionLightMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 144 13 Sample_NAudio
Fehler 31 Der Name "ExpressionLightMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 145 13 Sample_NAudio
Fehler 32 Der Name "DefaultThemeMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 154 13 Sample_NAudio
Fehler 33 Der Name "DefaultThemeMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 155 13 Sample_NAudio
Fehler 34 Der Name "ExpressionDarkMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 156 13 Sample_NAudio
Fehler 35 Der Name "ExpressionDarkMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 157 13 Sample_NAudio
Fehler 36 Der Name "ExpressionLightMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 158 13 Sample_NAudio
Fehler 37 Der Name "ExpressionLightMenuItem" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 159 13 Sample_NAudio
Fehler 38 Der Name "FileText" ist im aktuellen Kontext nicht vorhanden. C:\Users\Freefall\Desktop\Source\Sample_NAudio\MainWindow.xaml.cs 188 17 Sample_NAudio
And I recognized that there are no userforms and toolbox elements existing in the example. I think the example was not completely provided ....
|
|
|
|
Or are the xaml files the winforms? I´m confused :S I´m a VB programmer...
|
|
Coordinator
Feb 4 at 10:23 AM
|
XAML files are used with WPF, not winforms
|
|
|
|
And how should it then help me to get a winforms spectrum Display with NAudio? Unfortunately your demo app sc can´t be compiled due to .net and VS Version Problems: I use VS 2008, .NET 3.5 and I can´t get along with the wpf things.
|
|
Coordinator
Feb 5 at 8:46 AM
|
I'm afraid I haven't got an example of drawing spectrum in WinForms. You'd need to do it using the Graphics object in the Paint method.
|
|
|
|
:( Too bad. I have no clue how to start... I thought that you would have an exmple for winforms as you provide the dsp class. Would be fantastic if you would show the usage with an winforms example!
|
|