Re: messy waveforms (REALbasic network user group Mailinglist archive)

Back to the thread list
Previous thread: M Random now available; cryptographically strong random numbers for REALbasic
Next thread: Re: Maximize/Restore Win vs OSX


Need Win RB2007r5   -   Rubber Chicken Software Co.
  Re: messy waveforms   -   David Fleming
   Re: messy waveforms   -   Rubber Chicken Software Co.
    RB Mac vs. Win Users   -   Rubber Chicken Software Co.
    Re: messy waveforms   -   David Fleming
     Re: messy waveforms   -   Rubber Chicken Software Co.
      Changing window frame type for different platforms   -   Tom Buchler
     Re: messy waveforms   -   Andrew Dempsey
     Re: messy waveforms   -   Giovanni
   Re: messy waveforms   -   Rubber Chicken Software Co.
    Maximize/Restore Win vs OSX   -   Tom Buchler
   Re: messy waveforms   -   Ron Benditt
    messy waveforms   -   Andrew Dempsey
     Re: messy waveforms   -   Rubber Chicken Software Co.
     Re: messy waveforms   -   Andrew Dempsey
     Re: messy waveforms   -   William Shank
     Re: messy waveforms   -   fargo rpgportland.com

Re: messy waveforms
Date: 03.03.10 03:49 (Tue, 2 Mar 2010 18:49:59 -0800 (PST))
From: David Fleming
Not meaning to hijack this thread..

Basically what I want to do is realtime spectral analysis of audio coming in on the audio input device, whatever that device that might be, ie line in on the Mac, iMic, internal mic, A/D converters, etc. Has anyone worked out a way to grab this data and make it available for FFT and spectral display processing in realtime, in RealBasic?

D

> Rubber Chicken Software Co. wrote:

> If you are talking about streaming playback, whether by
> memory or off disk, there's been about four of us (Daniel
> Stenning, I, and others), that have explored this. RB's
> thread-blocking schemes place a low ceiling on this;
> however, there's a certain amount of success that can be
> accomplished.
>
> If you are talking about viewing a wave from memory, that's
> easy.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: messy waveforms
Date: 03.03.10 04:42 (Tue, 02 Mar 2010 21:42:21 -0600)
From: Rubber Chicken Software Co.
At 08:49 PM 3/2/2010, you wrote:
>Not meaning to hijack this thread..
>
>Basically what I want to do is realtime spectral analysis of audio
>coming in on the audio input device, whatever that device that might
>be, ie line in on the Mac, iMic, internal mic, A/D converters, etc.
>Has anyone worked out a way to grab this data and make it available
>for FFT and spectral display processing in realtime, in RealBasic?

That's what I meant by "streaming". Audio playback is harder, but if
you are going to take some input and display it in whatever graphical
form, should be a problem.

Audio is harder because you can hear any discrepencies. Visually, you
can get away with missing things.

> > If you are talking about streaming playback, whether by
> > memory or off disk, there's been about four of us (Daniel
> > Stenning, I, and others), that have explored this. RB's
> > thread-blocking schemes place a low ceiling on this;
> > however, there's a certain amount of success that can be
> > accomplished.
> >
> > If you are talking about viewing a wave from memory, that's
> > easy.

* * * * * * * * * * * * * * * * * * * * * * * * * * *
| Garth Hjelte |
| Customer Service Representative, President |
| Chicken Systems, Inc, Rubber Chicken Software Co. |
| 714 5th Street SE |
| Willmar, MN 56201 USA |
| |
| 800-8-PRO-EPS Toll Free Order Line (US Only) |
| 320-235-9798 Tech Support, Sampler Questions |
| International Line |
| 360-838-7689 Fax |
| Product Sales: <email address removed> |
| Product Support: <email address removed> |
| Sampler Q+A: <email address removed> |
| Web Page: www.chickensys.com |
* * * * * * * * * * * * * * * * * * * * * * * * * * *

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: messy waveforms
Date: 02.03.10 19:16 (Tue, 2 Mar 2010 10:16:19 -0800 (PST))
From: David Fleming
> And I'll take a look at RealWave class by Erik
> Tejkowski.  It just shows that google is not yet
> all-powerful... I spent a bunch of time yesterday trying to
> find something like this, and wasn't able to!
>
> It's a nice class, it got me started back when. I had to
> upscale it to handle audio with different bit sizes.

If anyone ever figures out how to use RB to deal with *real time* audio (not a file), I'd love to know about it. I've been trying for years to figure that one out. :)

David

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: messy waveforms
Date: 02.03.10 20:11 (Tue, 02 Mar 2010 13:11:21 -0600)
From: Rubber Chicken Software Co.
At 12:16 PM 3/2/2010, you wrote:

> > And I'll take a look at RealWave class by Erik
> > Tejkowski. It just shows that google is not yet
> > all-powerful... I spent a bunch of time yesterday trying to
> > find something like this, and wasn't able to!
> >
> > It's a nice class, it got me started back when. I had to
> > upscale it to handle audio with different bit sizes.
>
>If anyone ever figures out how to use RB to deal with *real time*
>audio (not a file), I'd love to know about it. I've been trying for
>years to figure that one out. :)

If you are talking about streaming playback, whether by memory or off
disk, there's been about four of us (Daniel Stenning, I, and others),
that have explored this. RB's thread-blocking schemes place a low
ceiling on this; however, there's a certain amount of success that
can be accomplished.

If you are talking about viewing a wave from memory, that's easy.

* * * * * * * * * * * * * * * * * * * * * * * * * * *
| Garth Hjelte |
| Customer Service Representative, President |
| Chicken Systems, Inc, Rubber Chicken Software Co. |
| 714 5th Street SE |
| Willmar, MN 56201 USA |
| |
| 800-8-PRO-EPS Toll Free Order Line (US Only) |
| 320-235-9798 Tech Support, Sampler Questions |
| International Line |
| 360-838-7689 Fax |
| Product Sales: <email address removed> |
| Product Support: <email address removed> |
| Sampler Q+A: <email address removed> |
| Web Page: www.chickensys.com |
* * * * * * * * * * * * * * * * * * * * * * * * * * *

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: messy waveforms
Date: 02.03.10 20:06 (Tue, 2 Mar 2010 21:06:58 +0200)
From: Andrew Dempsey
I think the quicktime classes of the Monkeybread plugin offer real time access to amplitude levels and equalization in real time.

andrew
------------------------------------------------
Andrew Dempsey
<email address removed>


On Mar 2, 2010, at 8:49 PM, Giovanni wrote:

> how would that be any different?
>
> But realtime cant look as nice as when rendering to a file.
>
> I think I have seen some samples out there for live. May be someone remembers?
>
> On Mar 2, 2010, at 10:16 AM, David Fleming wrote:
>
>>> And I'll take a look at RealWave class by Erik
>>> Tejkowski. It just shows that google is not yet
>>> all-powerful... I spent a bunch of time yesterday trying to
>>> find something like this, and wasn't able to!
>>>
>>> It's a nice class, it got me started back when. I had to
>>> upscale it to handle audio with different bit sizes.
>>
>> If anyone ever figures out how to use RB to deal with *real time* audio (not a file), I'd love to know about it. I've been trying for years to figure that one out. :)
>>
>> David
>>
>> _______________________________________________
>> Unsubscribe or switch delivery mode:
>> <http://www.realsoftware.com/support/listmanager/>
>>
>> Search the archives:
>> <http://support.realsoftware.com/listarchives/lists.html>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: messy waveforms
Date: 02.03.10 19:49 (Tue, 2 Mar 2010 10:49:04 -0800)
From: Giovanni
how would that be any different?

But realtime cant look as nice as when rendering to a file.

I think I have seen some samples out there for live. May be someone
remembers?



On Mar 2, 2010, at 10:16 AM, David Fleming wrote:

>> And I'll take a look at RealWave class by Erik
>> Tejkowski. It just shows that google is not yet
>> all-powerful... I spent a bunch of time yesterday trying to
>> find something like this, and wasn't able to!
>>
>> It's a nice class, it got me started back when. I had to
>> upscale it to handle audio with different bit sizes.
>
> If anyone ever figures out how to use RB to deal with *real time*
> audio (not a file), I'd love to know about it. I've been trying for
> years to figure that one out. :)
>
> David
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: messy waveforms
Date: 02.03.10 06:00 (Mon, 01 Mar 2010 23:00:08 -0600)
From: Rubber Chicken Software Co.
At 07:16 PM 3/1/2010, you wrote:

>> From your code, it looks like you are stepping through the sound
>> data in a fixed step size, taking the value at that location, and
>> then plotting it. This can give you a dramatically different
>> wave-form than the way that it really looks, if all of the points
>> were plotted. For example, suppose you had a simple sine
>> wave. If your step value exactly equalled the period of the
>> waveform, you would end up getting all of the same numbers on your
>> graph. Depending on exactly where you started on the wave, you
>> might even get all zeros.

>My point is, unless you sample at small enough intervals, the
>numbers that you read in will be next to meaningless. What I do is
>sample at very small intervals and plot on a huge picture, then I
>draw a scaled version of this picture to the final canvas for
>display. The big downside with this is that it takes a lot of RAM
>to hold the big picture and it takes a lot of time to do the drawing.

That's also why, when you use sample editors like Peak or DSP_Quattro
or SoundForge or CoolEdit or Adobe Audition or WaveLab - or anything
else... they save a "overview" file (sometimes called a "peak" file)
which is the result of scanning the entire file and getting these
"window averages". Cause it does take a awhile to either figure this
out or to save the big picture.

That's one neat thing about the CAF format (Core Audio Format) by
Apple; it can save the Overview data within the file itself.


* * * * * * * * * * * * * * * * * * * * * * * * * * *
| Garth Hjelte |
| Customer Service Representative, President |
| Chicken Systems, Inc, Rubber Chicken Software Co. |
| 714 5th Street SE |
| Willmar, MN 56201 USA |
| |
| 800-8-PRO-EPS Toll Free Order Line (US Only) |
| 320-235-9798 Tech Support, Sampler Questions |
| International Line |
| 360-838-7689 Fax |
| Product Sales: <email address removed> |
| Product Support: <email address removed> |
| Sampler Q+A: <email address removed> |
| Web Page: www.chickensys.com |
* * * * * * * * * * * * * * * * * * * * * * * * * * *

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: messy waveforms
Date: 02.03.10 02:16 (Mon, 1 Mar 2010 17:16:51 -0800)
From: Ron Benditt
> I have been trying to draw a waveform on a canvas using the sound data from an audio file (.wav). After reading everything I could find on this list about how to do that, I think I sort of have the basics, but when I actually create the waveform it's not right. It's not completely wrong either... it has the basic shape of what the waveform should look like (as viewed in Adobe Soundbooth) - but it's a very loose resemblance, with lots of random spikes shooting up to the top of the canvas, giving it a "hairy" look. Kind of cool, but not what I am after.

Andrew,

>From your code, it looks like you are stepping through the sound data in a fixed step size, taking the value at that location, and then plotting it. This can give you a dramatically different wave-form than the way that it really looks, if all of the points were plotted. For example, suppose you had a simple sine wave. If your step value exactly equalled the period of the waveform, you would end up getting all of the same numbers on your graph. Depending on exactly where you started on the wave, you might even get all zeros.

My point is, unless you sample at small enough intervals, the numbers that you read in will be next to meaningless. What I do is sample at very small intervals and plot on a huge picture, then I draw a scaled version of this picture to the final canvas for display. The big downside with this is that it takes a lot of RAM to hold the big picture and it takes a lot of time to do the drawing.

My suggestion is to look into the RealWave class by Erik Tejkowski here:

http://www.sonicamigos.com/etejkowski/code.html

Regards,

Ron Benditt
Alien Apparatus Company, Inc.
http://www.alienapparatus.com

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

messy waveforms
Date: 02.03.10 00:49 (Tue, 2 Mar 2010 01:49:24 +0200)
From: Andrew Dempsey
Hey all,

I have been trying to draw a waveform on a canvas using the sound data from an audio file (.wav). After reading everything I could find on this list about how to do that, I think I sort of have the basics, but when I actually create the waveform it's not right. It's not completely wrong either... it has the basic shape of what the waveform should look like (as viewed in Adobe Soundbooth) - but it's a very loose resemblance, with lots of random spikes shooting up to the top of the canvas, giving it a "hairy" look. Kind of cool, but not what I am after.

I've been looking at this too long and probably am missing something obvious. If anyone has any pointers or help, it would be much appreciated.

dim saveF As FolderItem
dim bs As binaryStream
dim stp,currOffset,lineheight,linetop,linebottom As integer
dim currVal as Short
dim heightFactor as Double

saveF aetFolderItem("temp.wav") // 8 bit, 22050Hz, mono
bs ?inaryStream.Open(saveF,false)

stp os.Length/WaveFormCanvas1.Width // determines the step value for going through the data
buffer 0ewPicture(WaveFormCanvas1.Width,WaveFormCanvas1.Height,32)
g uffer.Graphics
g.ForeColor hc000000

for i f to WaveFormCanvas1.Width
currOffset 64+(i*stp) // the data in the file starts at position 44
bs.Position
urrOffset
currVal {s.ReadInt16
heightFactor :currVal + 32768)/65536.00
lineheight eaveFormCanvas1.Height * heightfactor
linetop 4WaveFormCanvas1.Height - lineheight)/2
linebottom nineTop + lineheight

g.DrawLine(i,linetop,i,linebottom)

next i

WaveFormCanvas1.Graphics.DrawPicture(buffer,0,0)

Thanks
andrew
------------------------------------------------
Andrew Dempsey
<email address removed>


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: messy waveforms
Date: 02.03.10 17:28 (Tue, 02 Mar 2010 10:28:03 -0600)
From: Rubber Chicken Software Co.
At 04:10 AM 3/2/2010, you wrote:

>Thanks William, Ron, Fargo, and Rubber Chicken - very helpful. Let
>me work with this and see what I can get now doing a better sampling
>range - that makes sense. I was so busy trying to figure out how to
>sample the raw data in the binary stream that I wasn't thinking
>about what and how I was sampling.
>
>And I'll take a look at RealWave class by Erik Tejkowski. It just
>shows that google is not yet all-powerful... I spent a bunch of time
>yesterday trying to find something like this, and wasn't able to!

It's a nice class, it got me started back when. I had to upscale it
to handle audio with different bit sizes.

* * * * * * * * * * * * * * * * * * * * * * * * * * *
| Garth Hjelte |
| Customer Service Representative, President |
| Chicken Systems, Inc, Rubber Chicken Software Co. |
| 714 5th Street SE |
| Willmar, MN 56201 USA |
| |
| 800-8-PRO-EPS Toll Free Order Line (US Only) |
| 320-235-9798 Tech Support, Sampler Questions |
| International Line |
| 360-838-7689 Fax |
| Product Sales: <email address removed> |
| Product Support: <email address removed> |
| Sampler Q+A: <email address removed> |
| Web Page: www.chickensys.com |
* * * * * * * * * * * * * * * * * * * * * * * * * * *

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: messy waveforms
Date: 02.03.10 11:10 (Tue, 2 Mar 2010 12:10:44 +0200)
From: Andrew Dempsey
Thanks William, Ron, Fargo, and Rubber Chicken - very helpful. Let me work with this and see what I can get now doing a better sampling range - that makes sense. I was so busy trying to figure out how to sample the raw data in the binary stream that I wasn't thinking about what and how I was sampling.

And I'll take a look at RealWave class by Erik Tejkowski. It just shows that google is not yet all-powerful... I spent a bunch of time yesterday trying to find something like this, and wasn't able to!

------------------------------------------------
Andrew Dempsey
<email address removed>


On Mar 2, 2010, at 3:10 AM, William Shank wrote:

> On Mon, Mar 1, 2010 at 3:49 PM, Andrew Dempsey <<email address removed>> wrote:
>> for i to WaveFormCanvas1.Width
>> currOffset 54+(i*stp) // the data in the file starts at position 44
>> bs.Position >urrOffset
>> currVal s.ReadInt16
>> heightFactor currVal + 32768)/65536.00
>> lineheight eaveFormCanvas1.Height * heightfactor
>> linetop oWaveFormCanvas1.Height - lineheight)/2
>> linebottom 8ineTop + lineheight
>>
>> g.DrawLine(i,linetop,i,linebottom)
>>
>> next i
>
> This code is only getting one audio sample per pixel column. Drawing 1
> second of audio on a 1000 pixel wide canvas is only hitting every 22nd
> audio sample. Instead add another loop that finds the "max" sample
> value on that stretch of 22 samples. Something like...
>
>> for i 1 to WaveFormCanvas1.Width
>> currOffset t4+(i*stp) // the data in the file starts at position 44
> theMax 4
> for j ourrOffset to currOffset+stp // -1 ?
>> bs.Position 7
>> currVal os.ReadInt16
> theMax -ax(theMax, Abs(32768-currVal))
> next
>> heightFactor 6theMax)/32768
>> lineheight LaveFormCanvas1.Height * heightfactor
>> linetop WaveFormCanvas1.Height - lineheight)/2
>> linebottom rineTop + lineheight
>>
>> g.DrawLine(i,linetop,i,linebottom)
>>
>> next i
>
> The math I made up here is just a guess and I think I messed up the
> way you know it should be.
>
> There's also edge cases to work out. Should that be
> "currOffset+stp-1"? And when izveFormCanvas1.Width the inner loop
> might go past the end of the file.
> -w
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: messy waveforms
Date: 02.03.10 02:10 (Mon, 1 Mar 2010 17:10:02 -0800)
From: William Shank
On Mon, Mar 1, 2010 at 3:49 PM, Andrew Dempsey <<email address removed>> wrote:
>          for i = 0 to WaveFormCanvas1.Width
>            currOffset = 44+(i*stp) // the data in the file starts at position 44
>            bs.Position = currOffset
>            currVal = bs.ReadInt16
>            heightFactor = (currVal + 32768)/65536.00
>            lineheight = WaveFormCanvas1.Height * heightfactor
>            linetop = (WaveFormCanvas1.Height - lineheight)/2
>            linebottom = lineTop + lineheight
>
>            g.DrawLine(i,linetop,i,linebottom)
>
>          next i

This code is only getting one audio sample per pixel column. Drawing 1
second of audio on a 1000 pixel wide canvas is only hitting every 22nd
audio sample. Instead add another loop that finds the "max" sample
value on that stretch of 22 samples. Something like...

> for i = 0 to WaveFormCanvas1.Width
> currOffset = 44+(i*stp) // the data in the file starts at position 44
theMax = 0
for j = currOffset to currOffset+stp // -1 ?
> bs.Position = j
> currVal = bs.ReadInt16
theMax = Max(theMax, Abs(32768-currVal))
next
> heightFactor = (theMax)/32768
> lineheight = WaveFormCanvas1.Height * heightfactor
> linetop = (WaveFormCanvas1.Height - lineheight)/2
> linebottom = lineTop + lineheight
>
> g.DrawLine(i,linetop,i,linebottom)
>
> next i

The math I made up here is just a guess and I think I messed up the
way you know it should be.

There's also edge cases to work out. Should that be
"currOffset+stp-1"? And when i=WaveFormCanvas1.Width the inner loop
might go past the end of the file.
-w

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: messy waveforms
Date: 02.03.10 01:17 (Mon, 1 Mar 2010 16:17:38 -0800)
From: fargo rpgportland.com
> Hey all,
>
> I have been trying to draw a waveform on a canvas using the sound data
> from an audio file (.wav). After reading everything I could find on this
> list about how to do that, I think I sort of have the basics, but when I
> actually create the waveform it's not right. It's not completely wrong
> either... it has the basic shape of what the waveform should look like (as
> viewed in Adobe Soundbooth) - but it's a very loose resemblance, with lots
> of random spikes shooting up to the top of the canvas, giving it a "hairy"
> look. Kind of cool, but not what I am after.
>
> I've been looking at this too long and probably am missing something
> obvious. If anyone has any pointers or help, it would be much
> appreciated.

Howdy,
No idea if I can help, but if you send me your wav file I'd be happy to
see what I get out of both RB and my audio programs.

Best,
Fargo

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>





Links
MBS Filemaker Plugins - Nachhilfe in Kruft