Recent

Author Topic: Bitmap wavefore from .wav file  (Read 18427 times)

user5

  • Full Member
  • ***
  • Posts: 247
Bitmap wavefore from .wav file
« on: April 06, 2014, 09:37:24 am »
I'm on a quest to figure out how to draw a bitmap waveform from a .wav file and I would rent my soul to do that because otherwise I'll have to capture another program's waveform graphic. Even a simple VU meter in Pascal or C would help me to make a crude but good one.

I've got the source code for the sound programs ACS and Audacity but I'm afraid that I'll have trouble loading them correctly into Lazarus. Can anyone point me into the right direction?

karaba

  • New Member
  • *
  • Posts: 49
Re: Bitmap wavefore from .wav file
« Reply #1 on: April 06, 2014, 10:12:14 am »
well the idea is simple, a wav, to put it simple, is a bunch of numbers on after an other, those numbers can be transformed to a percentage system and shown inside a specific area, lets say 100 pixels high, now those numbers are to be translated on the Y axis of the area while each value is one position on the X axis of the area making it the time axis.

That is the main idea of drawing a wave form, by the way in order to connect those points you use a simple lineto method which uses the last known position as the start point and the new position you provide as the end point of a line.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Bitmap wavefore from .wav file
« Reply #2 on: April 06, 2014, 10:20:29 am »
Even a simple VU meter in Pascal or C would help me to make a crude but good one.
Searching the forum (and wiki) for the right terms can help - searching for vumeter gave this:
http://forum.lazarus.freepascal.org/index.php/topic,17599.msg138180.html#msg138180
perhaps that lib has other demo programs/controls that can show waveforms already...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: Bitmap wavefore from .wav file
« Reply #3 on: April 06, 2014, 01:41:31 pm »
Quote
perhaps that lib has other demo programs/controls that can show waveforms already...

Hum, not yet, but like BigChimp said, there is vu meters example in uos demo package...  ;) (and follow then the idea of karaba)
« Last Edit: April 06, 2014, 01:55:40 pm by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

user5

  • Full Member
  • ***
  • Posts: 247
Re: Bitmap wavefore from .wav file
« Reply #4 on: April 06, 2014, 05:19:43 pm »
Well, I found a great program called Waveform.exe and it's the Windows binary waveform generator. You enter
the name of a wave file and the name of a file to save the graphic into and it makes a graphic .png file. It also accepts flac files. If the amplitude of the wave file is low then the sound spikes in the .png file will be very small but simply raising the volume of the wave file and then running it through Waveform
again solves the problem. If anyone is interested, Waveform can be found at:

http://www.hydrogenaudio.org/forums/index.php?showtopic=100036

Look for message posts #5 and #7 near the bottom of the page. Thanks for your responses! It's a very nice program.

user5

  • Full Member
  • ***
  • Posts: 247
Re: Bitmap wavefore from .wav file
« Reply #5 on: April 07, 2014, 12:49:44 am »
I just found out one last bit of info for anyone who might ever use the  waveform generator waveform.exe:
This program gives the user the option to specify the width and height of the .png file, which causes the waveform
to shrink or stretch and this can be useful to get longer sound spikes. In effect, you raise the amplitude of the .png graphic representation w/o
having to run waveform again!

By the way, I noticed my typo error in this thread title. Thanks again. I'll keep tabs on this forum. Sorry about my
excess of enthusiasm but Waveform is
a gem! So is Lazarus, C, Delphi and Pascal. I also saw a function in C code
that makes some nice spikes.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Bitmap wavefore from .wav file
« Reply #6 on: April 07, 2014, 12:34:43 pm »
Forgive me if I"m less than enthusiastic about a third party exe rather than a native Lazarus/FPC solution... but glad you got what you needed!
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

user5

  • Full Member
  • ***
  • Posts: 247
Re: Bitmap wavefore from .wav file
« Reply #7 on: April 08, 2014, 05:33:29 pm »
Well, you are absolutely correct and my enthusiasm has dimmed, but I was desperate. This is the last stumbling block against continuing forward with my program. Not only that, but using this particular executable causes a blank window to appear and disappear plus the fact that Lazarus won’t allow some commands to heep it hidden (using recorder and TProcessUTF8). I may search again for something more code related but it’s hard; there’s a real propietary attitude out there and good info is the hardest to get. All I really need is a simple VU meter to get the highs and lows of speech and I could do the rest using time itself to make a decent and desirably simple wave. Thanks for your comments, which made me thoughtful.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Bitmap wavefore from .wav file
« Reply #8 on: April 08, 2014, 05:55:21 pm »
Proprietary? I don't see that at all.

Just check out the forum link to uos which is open source.

Also karaba explained a way to do things... I'm sure that you'll get all the help you need if you start implementing this yourself...
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: Bitmap wavefore from .wav file
« Reply #9 on: April 08, 2014, 06:42:01 pm »
Quote
perhaps that lib has other demo programs/controls that can show waveforms already...

=> https://github.com/fredvs/uos => /uos/examples/WaveForm.lpi

 ;)
« Last Edit: April 09, 2014, 12:46:50 am by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

user5

  • Full Member
  • ***
  • Posts: 247
Re: Bitmap wavefore from .wav file
« Reply #10 on: April 08, 2014, 11:36:11 pm »
I know what Karaba was talking about but the problem isn’t there, it’s in getting those plot points in the first place and the only way I can see to do that is either to read and decipher the wave file itself, which I and most others don’t know how to do, or to sample the wave file as it’s playing to get its changing volume. I’ve seen things like API GetWaveOutVolume and such but I think that refers to the sound card and windows mixer settings, not the wave itself. I did manage to get the open source for Audorra and it has 2 VU meters in it, but the simplest example of its player package is missing some units which I haven’t been able to find, namely auwave.pas, auwaveformat.pas and possibly others. I did manage to get some other Audorra demos to run and that’s a feat right there but I’ll check out your suggestions. Thanks again.

PS: I did download uos and tried to run it in Lazarus but when I tried to compile it I got an error message that said an illegal qualifier was being used. The line of code (in uos.pas) involved was: setlength(uosLevelArray[index].[InputIndex],0) ;  The cursor stopped at [InputIndex] This also happened with the waveform demo. Maybe I’m using the wrong version of Lazarus (1.0.10). I’m going to download Lazarus 1.2 and then I’ll try again.

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: Bitmap wavefore from .wav file
« Reply #11 on: April 08, 2014, 11:42:18 pm »
Quote
S: I did download uos and tried to run it in Lazarus but when I tried to compile it I got an error message that said an illegal qualifier was being used. The line of code (in uos.pas) involved was: setlength(uosLevelArray[index].[InputIndex],0) ;  The

Hum, what system are you using ? (Windows, osx, Linux ?)

[EDIT] Have you try to compile waveform.lpi ?
« Last Edit: April 08, 2014, 11:44:53 pm by Fred vS »
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: Bitmap wavefore from .wav file
« Reply #12 on: April 08, 2014, 11:54:46 pm »
Quote
Quote

    S: I did download uos and tried to run it in Lazarus but when I tried to compile it I got an error message that said an illegal qualifier was being used. The line of code (in uos.pas) involved was: setlength(uosLevelArray[index].[InputIndex],0) ;  The


Hum, what system are you using ? (Windows, osx, Linux ?)

[EDIT] Have you try to compile waveform.lpi ?

Hum, just tested on Windows and it works too.

PS : Do not use Debugger (too much calculation for him  :-X) and compile waveform.lpi
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's best friend
Re: Bitmap wavefore from .wav file
« Reply #13 on: April 09, 2014, 01:42:22 am »
Quote
The line of code (in uos.pas) involved was: setlength(uosLevelArray[index].[InputIndex],0) ;  The cursor stopped at [InputIndex] This also happened with the waveform demo. Maybe I’m using the wrong version of Lazarus (1.0.10).

Oops, i see what append => you are using fpc 2.6.2.

Im using fpc 2.7.1.

=> I will ask some help to forum...
I use Lazarus 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2292
    • havefunsoft.com
Re: Bitmap wavefore from .wav file
« Reply #14 on: April 09, 2014, 04:33:26 am »
Let me step on Fred vS toes (again) and suggest to use openal wav playback test :)

The reason - it has .wav loader.
Strip all the openal playback code and just paint the waveform ... hmm to a TBitmap.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz