[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
Last edited by Nightwalker83; May 19th, 2014 at 04:40 AM.
Reason: Not Resolved
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
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
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?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Re: [RESOLVED] Oscilloscope (sound wave graph) how do I create one
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
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.
Last edited by Nightwalker83; May 21st, 2014 at 01:36 AM.
Reason: Adding more!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
Re: Oscilloscope (sound wave graph) how do I create one
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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
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.
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
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Re: Oscilloscope (sound wave graph) how do I create one
Originally Posted by jmsrickland
Change Picture to Picture1
Change Picture1 and Picture2 to Pixels
Control names or which code are you referring to?
Switch to .WAV files
So I can't use an Oscilloscope with an other sound format other than .wav format?
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
Re: Oscilloscope (sound wave graph) how do I create one
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.
Last edited by jmsrickland; May 19th, 2014 at 07:59 PM.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Last edited by Nightwalker83; May 21st, 2014 at 01:32 AM.
Reason: Adding more!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
Re: Oscilloscope (sound wave graph) how do I create one
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
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?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Re: Oscilloscope (sound wave graph) how do I create one
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Re: Oscilloscope (sound wave graph) how do I create one
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?
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Re: Oscilloscope (sound wave graph) how do I create one
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?
Last edited by Nightwalker83; May 26th, 2014 at 08:22 PM.
Reason: Removed URL!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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:
for mp3's you need to manually decompress mp3 to wave, consider two waves for stereo and switch to dynamic drawing.
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.
Last edited by digitalShaman; May 24th, 2014 at 03:50 AM.
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.
Last edited by Nightwalker83; May 24th, 2014 at 07:56 AM.
Reason: Adding more!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
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.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Re: Oscilloscope (sound wave graph) how do I create one
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672