-
[RESOLVED] Oscilloscope (sound wave graph) how do I create one
Hi,
I was wondering how to create a oscilloscope in VB6 for use with normal sound (MP3, Wav) files and also microphone input too? I have read the VB6.0 – Sound and DirectXSound Tutorial here but I don’t know if that working with non-directX sound or if that whole project follows on from one section to another, meaning will I be able to use the Oscilloscope code without having to do the other parts in the tutorial first? If not could someone please post a non-directX version of the code.
Edit:
I am NOT looking for more examples. I am wanting to help to get the WavePlayerWithSineWaveDisplay1 code working in the demo project I posted in post #14.
Thanks,
Nightwalker
-
Re: Oscilloscope (sound wave graph) how do I create one
-
Re: Oscilloscope (sound wave graph) how do I create one
I believe jmsrickland has recently dealt with something like that. Try asking him about it.
-
Re: Oscilloscope (sound wave graph) how do I create one
@Rattled_Cage
That looks similar to the Oscilloscope project from http://www.studiolivraghi.it although, I am unsure how to convert it to use with sound files mentioned in the first post?
@Bonnie West
Searching the subject on the forums in appears that jmsrickland was dealing with it but I don't think he ever found a solution.
-
Re: Oscilloscope (sound wave graph) how do I create one
do you just want to load a wav and see the graph ?
have a look at this http://www.Planet-Source-Code.com/vb...62860&lngWId=1
-
1 Attachment(s)
Re: [RESOLVED] Oscilloscope (sound wave graph) how do I create one
Not sure what exactly you are looking for but here is a small and very simple sine wave generator in real time.
-
Re: [RESOLVED] Oscilloscope (sound wave graph) how do I create one
I used the code from post #5 although, I'm not sure if it is drawing the graph properly because all the graphs look like a rectangle.
-
Re: [RESOLVED] Oscilloscope (sound wave graph) how do I create one
The one I posted looks nothing like the one from #5. It's more like what you would see if you speak into a mic which is what it does. Very jagged display
-
2 Attachment(s)
Re: [RESOLVED] Oscilloscope (sound wave graph) how do I create one
Here's another "scope" that is just plotting a noisy sine wave generated via Timer ticks.
It uses the trick of sliding and swapping two "panel" PictureBox controls within a "viewport" PictureBox once one "scope width" has filled from left to right. This gives a continuous scrolling effect.
-
Re: [RESOLVED] Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
jmsrickland
The one I posted looks nothing like the one from #5. It's more like what you would see if you speak into a mic which is what it does. Very jagged display
How would I modify to include loaded files?
-
Re: [RESOLVED] Oscilloscope (sound wave graph) how do I create one
I don't know yet. That will be my next step to have sine wave with pre-recorded files.
-
Re: [RESOLVED] Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
jmsrickland
I don't know yet. That will be my next step to have sine wave with pre-recorded files.
I will change my project when you figure it out.
-
Re: [RESOLVED] Oscilloscope (sound wave graph) how do I create one
Did you look at the project I posted in the Code Bank in your Thread. It does what you want except it isn't true real time but it looks like it is.
-
Re: [RESOLVED] Oscilloscope (sound wave graph) how do I create one
Hi,
I can not seem to get the code in "WavePlayerWithSineWaveDisplay1.zip" working with my code in "Demo.zip" the problems should become clear once you run my project. Also you need to change "C:\Users\User\Desktop\Music\2pac - Until The End Of Time.mp3" in the play sub in the playerMethods module to a song of your choosing otherwise the project will not work. Also, I had to delete the "test1.wav" from "WavePlayerWithSineWaveDisplay1.zip" it made the total upload larger than the 500KB per post forum limit.
Edit: Deleted "WavePlayerWithSineWaveDisplay1.zip" as it was using "WaveIn" and "WaveOut" which, will not work with non .wav formats. See post #26 for new demo, the demo in this post still has the "WaveOut" code in it.
-
Re: Oscilloscope (sound wave graph) how do I create one
u need this
https://www.planet-source-code.com/v...70452&lngWId=1
open it check the very top one u need to extract that and put in your source code .
to first test it to make sure this is what your afa , play a music and put your audio settings to ( stereo ) mode this will listen to internal microphone you will se waves go with music
-
Re: Oscilloscope (sound wave graph) how do I create one
Are you referring to the code in the modules are the form?
-
Re: Oscilloscope (sound wave graph) how do I create one
i will make for u sorry for late reply , just to confirm u want that waving looking style while playing music ryt ?
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
cobraide
i will make for u sorry for late reply , just to confirm u want that waving looking style while playing music ryt ?
Yes, although, I don't want you to make me a demo but rather to me how to get the WavePlayerWithSineWaveDisplay1 code working in the demo project I posted in post #14.
-
5 Attachment(s)
Re: Oscilloscope (sound wave graph) how do I create one
:wave:
I found these in my collection of other peoples code ;)
Audio Spectrum
Spectrum Analysis
Oscilloscope
Dwl Oscilloscope
Mifft
I tried them all some time ago, some are :thumb: some are :down:
Zips enclosed ;)
Regards :)
-
Re: Oscilloscope (sound wave graph) how do I create one
Thanks! but I am NOT looking for more examples. I am wanting to help to get the WavePlayerWithSineWaveDisplay1 code working in the demo project I posted in post #14.
-
Re: Oscilloscope (sound wave graph) how do I create one
hi nightwalker,
i haven't got vb6 installed so i cannot run your code but i'll try to help anyway as i am quite familiar with the waveout stuff.
i was looking into your code and some things struck me:
- MP3Functions.cls: this is using mciSendString to play media. as far as i know this does not allow you the deep control needed to draw the waveform at the position that is currently played. i see you also have code using the wavout api in sine.bas maybe MP3Functions was included in the demo by mistake?
- In Sine.bas you have the lines
WaveOut.dwFlags = WaveOut.dwFlags Or WHDR_BEGINLOOP
WaveOut.dwFlags = WaveOut.dwFlags Or WHDR_ENDLOOP
this does not make sense as the latter will 'overwrite' the first. and at the same position WaveOut.dwBufferLength should be UBound(UsingWavSound())+1 i think.
- i see that you draw the entire wave form into frmMain.Picture prior to playing and then you attempt to slide the picbox (i assume underneath a 'viewport'). be aware that this method will not work well with long wave files but instead you should draw the wave on the fly.
- in your scrolling it appears that you should rather move frmMain.Picture instead of frmMain.Picture2. this is based on my assumption that Picture2 is the static viewport and Picture is the picturebox where the graph is and Picture is placed inside Picture2. therefore by moving Picture you change what you see in Picture2
- i would not use .move to move the picturebox but just set the .left property (this is the only one that changes as width, top and height stay the same)
- i think you rather want WaveOutTime.wType to be set to TIME_SAMPLES instead of TIME_BYTES. this would allow you to directly get from WaveOutTime.u to Picture.left
- your current code calculates sngPosition = WaveOutTime.u * nbrDivisions where nbrDivisions appears to be zero
depending on what you want to achieve you might need to completely rethink your approach. for example if you want to have a scrolling waveform for mp3's you need to manually decompress mp3 to wave, consider two waves for stereo and switch to dynamic drawing. all together what you want is not an easy task and taken into consideration what i saw in your code this currently might exceed your capabilities (no offence).
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
digitalShaman
- In Sine.bas you have the lines
WaveOut.dwFlags = WaveOut.dwFlags Or WHDR_BEGINLOOP
WaveOut.dwFlags = WaveOut.dwFlags Or WHDR_ENDLOOP
this does not make sense as the latter will 'overwrite' the first.
correction: forget what i said. the code is fine
-
Re: Oscilloscope (sound wave graph) how do I create one
For starters:
Change Picture to Picture1
Change Picture1 and Picture2 to Pixels
In sub DisplayGraph1 change Picture to Picture1 and Dim i As Long
Add your Timer code
Add your sinewaveDisplay sub
Switch to .WAV files
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
jmsrickland
Change Picture to Picture1
Change Picture1 and Picture2 to Pixels
Control names or which code are you referring to?
Quote:
Switch to .WAV files
So I can't use an Oscilloscope with an other sound format other than .wav format?
Quote:
Originally Posted by
digitalShaman
maybe MP3Functions was included in the demo by mistake?
No, I included it is there so you could actually see what happened when you went to play a song.
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
Nightwalker83
Control names or which code are you referring to?
So I can't use an Oscilloscope with an other sound format other than .wav format?
No, I included it is there so you could actually see what happened when you went to play a song.
I told you which sub to make the change from Picture to Picture1. I think you can figure out what I'm referring to.
I'm not saying you can't use .MP3 files to make an Oscilloscope but not by using waveOut APIs.
-
1 Attachment(s)
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
jmsrickland
I'm not saying you can't use .MP3 files to make an Oscilloscope but not by using waveOut APIs.
Well, I have removed the waveOut stuff in my project, I use "mciSendString" to do most of the work such as play the songs, pausing, etc.
Edit:
Here is the new demo.
Attachment 114377
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
Nightwalker83
Well, I have removed the waveOut stuff in my project, I use "mciSendString" to do most of the work such as play the songs, pausing, etc.
i need to repeat myself:
this is using mciSendString to play media. as far as i know this does not allow you the deep control needed to draw the waveform at the position that is currently played.
and
for example if you want to have a scrolling waveform for mp3's you need to manually decompress mp3 to wave, consider two waves for stereo and switch to dynamic drawing.
the thing is: for drawing the waveform you need to have the waveform i.e. the wave data. if you use mci to play the music mci does all the converting from mp3 to wave in the background without letting you know what the waveform looks like so you cannot draw anything and furthermore you do not get exact feedback from mci where in the song it currently is playing.
as far as i know you cannot achieve what you want using mci.
the way to do what you want, and this is a stony one, is to read the mp3 in chunks, convert the mp3 chunks to wave (ACM or lame.dll or the like), feed the wave data to the output device using waveout apis, get the currently playing position via waveOutGetPosition and draw the wave data at that position into a picbox.
this is for an oscilloscope (a nerviously flickering wave) as in the thread title. If you want a scrolling waveform like in DAW software, which is different from an oscilloscope, then you would need to read and convert the entire file first, draw your graph and then move it along with the current position.
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
digitalShaman
this is using mciSendString to play media. as far as i know this does not allow you the deep control needed to draw the waveform at the position that is currently played.
What should I be using to control the same functions as I already have (in "MP3Functions") rather than waveOut APIs or mciSendString if I want to use an Oscilloscope?
-
Re: Oscilloscope (sound wave graph) how do I create one
Funny that in your signatures you say DO NOT BUMP YOUR POSTS!!! yet you did that several times in this thread
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
jmsrickland
Funny that in your signatures you say DO NOT BUMP YOUR POSTS!!! yet you did that several times in this thread
Yes, you are correct but I wait at less 24 hours before bumping my threads! I think that post (#7) is more around doing repeated bumping within a 24 period.
Anyway back on topic.
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
jmsrickland
Funny that in your signatures you say DO NOT BUMP YOUR POSTS!!! yet you did that several times in this thread
;):pbump:p
-
Re: Oscilloscope (sound wave graph) how do I create one
I have sent a private message to Jacob Roman asking if he even received a solution to his Mp3 To Wav Wav To Mp3 Converter question because instead of finding an Oscilloscope that uses straight MP3 I was wondering I might be able to convert the MP3s to Wav format then use the Oscilloscope I wanted to originally to output the graph. rm_03 also, linked to some code that encodes wav to mp3 as well as with some configuring decodes mp3 to wav.
-
1 Attachment(s)
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
Nightwalker83
Or, you can try this one
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
jmsrickland
Or, you can try this one
Ah, I found an example using the "BASS.dll" on Planet Source Code (I think) created by B P Likith sai. Although, that only worked with version 1.4 of the "BASS.dll". Other versions such be available on un4seen.com, the BASS creator's website. The only this that seems to be missing with the example you posted is that doesn't keep track of the time left for the MP3 to Wav conversion. For some reason that data gets replaced by the position data? :confused:
-
Re: Oscilloscope (sound wave graph) how do I create one
The one I posted came from here and the person that posted it probably modified the one from PSC because it is the same as the one from BASS. It converts mp3 to wav and that's what I thought you wanted. Why do you care if it doesn't keep track of the time left as long as it converts you wind up with your wav data you need for your oscilloscope
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
jmsrickland
The one I posted came from here and the person that posted it probably modified the one from PSC because it is the same as the one from BASS. It converts mp3 to wav and that's what I thought you wanted. Why do you care if it doesn't keep track of the time left as long as it converts you wind up with your wav data you need for your oscilloscope
Ah ok! Well, I wasn't sure if the mp3 would have converted because the conversion only seem to take a number of seconds to complete. Although, I have tested it and there does not seem to be any problem with the length. I tried the following linked file with a wav converted from mp3 but the problem is that the code loads the wav into an array and seeing as the wav used to an mp3 the file is huge. For example "Taking Back Sunday - This Photograph Is Proof.mp3" is 44,500,044 bytes and hat is going to take a long time to read into an array such as this attachment does.
I am wondering how I would go about displaying the directly from the playing file rather than having to load it into an array then load the array data into the Oscilloscope?
-
Re: Oscilloscope (sound wave graph) how do I create one
i think i have already gave you an appropriate answer days ago giving you everything you need to know:
Quote:
for mp3's you need to manually decompress mp3 to wave, consider two waves for stereo and switch to dynamic drawing.
Quote:
read the mp3 in chunks, convert the mp3 chunks to wave (ACM or lame.dll or the like), feed the wave data to the output device using waveout apis, get the currently playing position via waveOutGetPosition and draw the wave data at that position into a picbox.
i have done something similar: record from input (WaveInApi) do FFT and draw spectrum, convert to mp3 and save, so i can say that i do quite know what i am talking about. If you are really serious with this you should first clearly define what you want in the end (Media Player? What formats to support? Osci? scrolling waveform? aso) then we all can dicuss what the best approach is then you need to start implementing this and if you run into troubles you can come back, post your code and ask questions. but be sure this is not something that you will have done in one week.
so far you have been flooded with examples and tipps but somehow i feel that you have not really made a true effort to analyze and understand both.
edit addition: of course there might be other ways to achieve this as well so i am not saying that my solution is the only one. there might be others as well and lastly it also (again) depends on your requirements. if you just want to have something that 'roughly' displays where you are and that just looks good then this is something different from having (as far as possible) exact knowledge where in the waveform the currently playing position is.
-
Re: Oscilloscope (sound wave graph) how do I create one
@digitalShaman,
I have managed to convert the MP3s in Wav format. The example post #36 can display the scope from a wav the problem is that it loading the wav into an array buffer then populates the scope from the array.
Edit:
I just came across pibasic while which, has several examples on the site on loading the wav file into the sound wave graph depending on which method you want to use.
-
Re: Oscilloscope (sound wave graph) how do I create one
Sounds like you want a real time wave graph. I may have one although I'm not sure now (it's been ages since I have messed around with this stuff) if it works 100% all the time I'll just have to go and find it and take a look.
It produces the wave graph at the same time it plays the wave file.
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
jmsrickland
Sounds like you want a real time wave graph. I may have one although I'm not sure now (it's been ages since I have messed around with this stuff) if it works 100% all the time I'll just have to go and find it and take a look.
It produces the wave graph at the same time it plays the wave file.
If you could find it that would be great! If not I will see if I can convert the example in post #36 to the same affect using the code linked to in post #38.
-
Re: Oscilloscope (sound wave graph) how do I create one
OK, It's isn't what I thought. It is basically the same as the other except it reads in the wav file in smaller chunks and produces a wave graph per chunck so it kind of gives the appearance of real-time but it still uses a byte array buffer which I think is what you do not want.
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
jmsrickland
OK, It's isn't what I thought. It is basically the same as the other except it reads in the wav file in smaller chunks and produces a wave graph per chunck so it kind of gives the appearance of real-time but it still uses a byte array buffer which I think is what you do not want.
Yes, because the demo in post #36 already does that and also as I mentioned it would take an extremely long time to load the data into the array if the file is as big as the one mentioned.
-
Re: Oscilloscope (sound wave graph) how do I create one
It wouldn't take a long time as it reads in small pieces of the file, produces the wave graph for that small piece then reads in another small piece etc, etc. so even if you have a very large wave file it still displays the wave graph as the file is being read instead of reading in the entire file first which is what the first example does. It's as close as I could get to real-time without it being true real-time.
I have another example using audio streaming which might be of interest but it is intergrated into a larger client/server application so extracting out the code could be a task.
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
jmsrickland
It wouldn't take a long time as it reads in small pieces of the file, produces the wave graph for that small piece then reads in another small piece etc, etc. so even if you have a very large wave file it still displays the wave graph as the file is being read instead of reading in the entire file first which is what the first example does. It's as close as I could get to real-time without it being true real-time.
Maybe I just thought it was taking a long time to input the data because there was not input time elapsed of the example thus I ended up stopping the example before the input had finish.
Quote:
I have another example using audio streaming which might be of interest but it is intergrated into a larger client/server application so extracting out the code could be a task.
Now I am curious to know what you are talking about!
-
Re: Oscilloscope (sound wave graph) how do I create one
In case this is thought for systems from Vista onwards, there's a relative simple approach over the CoreAudio-API.
CoreAudio supersedes the WaveIn/WaveOut API (both of those older Base-APIs are known to get sparse support
by some of the SoundCard-vendors, whilst CoreAudio should be supported by all of them in the meantime).
So it is (besides DirectX) the only reliable method to deal with Audio-Streams and -Devices on Vista+.
What CoreAudio allows for example, is the capturing of PCM-SoundBuffers, which were
"just send to the SoundCards outputlines" (no matter what the original encoding of
these sounds was, *.mp3 *.wav *.wma - all have to be decoded finally to produce
sound - and that is what CoreAudio is able to capture as some kind of "redirected-
input-source").
CoreAudio allows also the capturing of "official Hardware-InputSource-Lines" of course
(as e.g. Microphone-In - or Line-In) - but as said, the current output-buffers of the
soundcard can act as an Input-Line for the CoreAudio-recording-direction as well.
Below is all the code needed (all in a single Form) to accomplish an FFT- a Peak-
and also an Oscilloscope-RealTime-Rendering of the currently playing sound.
Depends on vbRichClient5, two PictureBoxes and a Timer on a Form.
Code:
Option Explicit
Const WavFreq As Long = 44100, WavChannels As Long = 2
Private SrfFFT As cCairoSurface, SrfOSC As cCairoSurface
Private WithEvents ACC As cAudioCaptureClient, FPS
Private Sub Form_Load()
ScaleMode = vbPixels
Set SrfFFT = Cairo.CreateSurface(200, 168)
picFFT.Move (ScaleWidth - SrfFFT.Width) / 2, 30, SrfFFT.Width, SrfFFT.Height
Set SrfOSC = Cairo.CreateSurface(400, 127)
picOSC.Move (ScaleWidth - SrfOSC.Width) / 2, 60 + SrfFFT.Height, SrfOSC.Width, SrfOSC.Height
Set ACC = New_c.AudioCaptureClient
ACC.InitOn New_c.MMDeviceEnumerator.GetDefaultAudioEndpoint(eRender, eConsole), WavFreq, WavChannels
ACC.RaiseMeterEvents = True
ACC.RaiseFFTEvents = True
ACC.FFTInputLevelFac = 0.8
ACC.StartStream
End Sub
Private Sub ACC_MeterInfo(ByVal LeftPeak As Single, ByVal RightPeak As Single, LeftFFT() As Single, RightFFT() As Single)
DrawFFT LeftPeak, RightPeak, LeftFFT, RightFFT
End Sub
Private Sub ACC_NextBuffer(ByVal pCaptureBuf As Long, ByVal CapturedBytes As Long, ByVal BufferFlags As AUDCLNT_BUFFERFLAGS)
Dim i As Long, ii As Long, PCM16BitStereo() As Integer, Float32BitLeft() As Single, Float32BitRight() As Single
If CapturedBytes < 8 Then Exit Sub
If CapturedBytes Mod 8 Then CapturedBytes = (CapturedBytes \ 8) * 8
ReDim PCM16BitStereo(0 To CapturedBytes \ 2 - 1)
ReDim Float32BitLeft(0 To (CapturedBytes \ 4) - 1)
ReDim Float32BitRight(0 To (CapturedBytes \ 4) - 1)
New_c.MemCopy VarPtr(PCM16BitStereo(0)), pCaptureBuf, CapturedBytes
For i = 0 To UBound(PCM16BitStereo) Step 4
Float32BitLeft(ii + ii) = ii
Float32BitLeft(ii + ii + 1) = PCM16BitStereo(i) / 1000
Float32BitRight(ii + ii) = ii
Float32BitRight(ii + ii + 1) = PCM16BitStereo(i + 1) / 1000
ii = ii + 1
Next i
If FPS Mod 2 = 0 Then DrawOsc Float32BitLeft, Float32BitRight
FPS = FPS + 1
End Sub
Private Sub DrawOsc(Float32BitLeft() As Single, Float32BitRight() As Single)
With SrfOSC.CreateContext
.SetSourceColor vbBlack
.Paint
.DrawLine .Surface.Width / 2, 0, .Surface.Width / 2, .Surface.Height, True, 1, vbGreen
.TranslateDrawings 0, .Surface.Height / 2
.ScaleDrawings .Surface.Width / (UBound(Float32BitLeft) + 1), .Surface.Height / 100
.SetLineWidth 1
.SetSourceColor vbRed
.PolygonSingle Float32BitLeft, False, splNone
.TranslateDrawings (UBound(Float32BitLeft) + 1) / 2, 0
.PolygonSingle Float32BitRight, False, splNone
.Stroke
.Surface.DrawToDC picOSC.hDC
End With
End Sub
Public Sub DrawFFT(ByVal LeftPeak As Single, ByVal RightPeak As Single, LeftFFT() As Single, RightFFT() As Single)
Dim i As Long, y As Double, mOffsX As Double, WScale As Long, Pat As cCairoPattern
Static TopLPeak As Single, TopRPeak As Single, TopLFFT(0 To 19) As Single, TopRFFT(0 To 19) As Single
LeftPeak = Log(1.00000000000001 + LeftPeak * 9) / 2.303
RightPeak = Log(1.00000000000001 + RightPeak * 9) / 2.303
With SrfFFT.CreateContext
.SetSourceColor vbBlack, 0.22
.Paint
.Save
mOffsX = 11
WScale = SrfFFT.Width \ 2 - mOffsX - 6
'draw the FFT-bars
.TranslateDrawings SrfFFT.Width \ 2 - 3, SrfFFT.Height
.ScaleDrawings 1, -1 '<- bottom-up-coord-system
y = 5
For i = 0 To UBound(LeftFFT)
If TopLFFT(i) <= LeftFFT(i) Then TopLFFT(i) = LeftFFT(i) Else If TopLFFT(i) > 0.008 Then TopLFFT(i) = TopLFFT(i) - 0.008
.DrawLine -mOffsX - TopLFFT(i) * (WScale + 4), y, -mOffsX - TopLFFT(i) * WScale, y, True, 5, vbYellow, 0.3
.DrawLine -mOffsX, y, -mOffsX - LeftFFT(i) * WScale, y, True, 5, &H40FF&, 0.6
If TopRFFT(i) <= RightFFT(i) Then TopRFFT(i) = RightFFT(i) Else If TopRFFT(i) > 0.008 Then TopRFFT(i) = TopRFFT(i) - 0.008
.DrawLine mOffsX + TopRFFT(i) * (WScale + 4), y, mOffsX + TopRFFT(i) * WScale, y, True, 5, vbYellow, 0.3
.DrawLine mOffsX, y, mOffsX + RightFFT(i) * WScale, y, True, 5, &H40FF&, 0.6
y = y + 8
Next i
y = y - 5
'the Peak-indicators use a "green-yellow-red-pattern"
If TopLPeak <= LeftPeak Then TopLPeak = LeftPeak Else If TopLPeak > 0.007 Then TopLPeak = TopLPeak - 0.007
If TopRPeak <= RightPeak Then TopRPeak = RightPeak Else If TopRPeak > 0.007 Then TopRPeak = TopRPeak - 0.007
.SetLineWidth 0
Set Pat = Cairo.CreateLinearPattern(0, 0, 0, y)
Pat.AddColorStop 0, vbGreen, 0.5
Pat.AddColorStop 0.6, vbYellow, 1
Pat.AddColorStop 1, vbRed, 1
.Rectangle -4, 2 + TopLPeak * y, 6, 4 * TopLPeak, True
.Rectangle -4, 2, 6, LeftPeak * y, True
.Rectangle 3, 2 + TopRPeak * y, 6, 4 * TopRPeak, True
.Rectangle 3, 2, 6, RightPeak * y, True
.Fill , Pat
.Restore
End With
SrfFFT.DrawToDC picFFT.hDC
End Sub
Private Sub Timer1_Timer()
Caption = FPS: FPS = 0
End Sub
Private Sub Form_Terminate()
If Forms.Count = 0 Then New_c.CleanupRichClientDll
End Sub
Here's what the above code puts out (Stereo-LeftChannel to the left-hand-side of the form - and the right channel to the right):
http://vbRichClient.com/Downloads/SoundCapturing.png
If there's an interest in this stuff, I can also put up a downloadable example (with a few more comments) into the CodeBank.
Olaf
-
Re: Oscilloscope (sound wave graph) how do I create one
I have a vb6 project on XP that gives me that same effect using only plain waveOut and no dependencies.
-
Re: Oscilloscope (sound wave graph) how do I create one
@Schmidt
I receive Error '9' Subscript out of range
Code:
Float32BitLeft(ii + ii + 1) = PCM16BitStereo(i) / 1000
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
Nightwalker83
@Schmidt
I receive Error '9' Subscript out of range
Code:
Float32BitLeft(ii + ii + 1) = PCM16BitStereo(i) / 1000
Will upload an Example to the codebank...
@jmsrickland
If you have the same example for XP, then it would need to work per
WaveIn-API (capturing the sound from the WaveOut-Destination-line,
involving fiddeling with the Mixer-API, to find the "reflection-point where to capture from".
Would like to take a look at that, so if you have a link, this would be nice.
Olaf
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
Nightwalker83
@Schmidt
I receive Error '9' Subscript out of range
Code:
Float32BitLeft(ii + ii + 1) = PCM16BitStereo(i) / 1000
Found a mistake I made in calculating the Ubounds for the different Buffers -
updated post #45 with a corrected ACC_NextBuffer event-routine.
Maybe that helps already.
Olaf
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
Schmidt
Found a mistake I made in calculating the Ubounds for the different Buffers -
updated post #45 with a corrected ACC_NextBuffer event-routine.
Thanks! I will try the new code and see if it works.
Edit:
The new code works without any problems.
-
Re: Oscilloscope (sound wave graph) how do I create one
Quote:
Originally Posted by
jmsrickland
I have a vb6 project on XP that gives me that same effect using only plain waveOut and no dependencies.
Any luck with this?
Edit:
Is this the project you were thinking of?