AudioWaveform

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bernd59
Posts: 10
Joined: Sat Nov 11, 2017 12:21 pm

AudioWaveform

Post by bernd59 » Sun Feb 25, 2018 4:14 pm

Dear all
I want to access sample values of a audio file (uncompressed: wav)
I got a rev-code for that from a friend: AudioWaveform.rev
But I can not load a wav file in that .rev stack using LiveCode 9
Does anyone know a newer version of AudioWaveform ?

Or a more general question: I found -> customProperties["FileInfo"]
which allows me to read the file header.
Does anyone know how to access the same-values of a wav-file in order to display an oscillogram?

Best
Bernd

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: AudioWaveform

Post by [-hh] » Tue Feb 27, 2018 5:27 pm

There are *mighty* cross-platform tools available that can (also) create waveforms.

1. CLIs, you can use them from LiveCode via shell():

audiowaveform
https://github.com/bbc/audiowaveform
(can also create the data as json file if you wish to make your own)

ffmpeg
https://www.ffmpeg.org , especially
https://trac.ffmpeg.org/wiki/Waveform

Makes not a waveform but a spectrogram:
SOX
http://sox.sourceforge.net

2. Or, very comfortable, but you have to wait until the browser widget supports Web Audio:
wavesurfer.js
https://wavesurfer-js.org
shiftLock happens

bernd59
Posts: 10
Joined: Sat Nov 11, 2017 12:21 pm

Re: AudioWaveform

Post by bernd59 » Wed Feb 28, 2018 7:05 am

thanks a lot!
so, I know that liveCode does not supports only play audio directly.
so, If I want to display an oszillogram and a spectrogram in Livecode at least for short audios it is the best way to calculate these osz-data and spec-data outside livecode, import these data and display them in my LiveCode app.??
Best
Bernd

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: AudioWaveform

Post by [-hh] » Wed Feb 28, 2018 8:29 am

Yes. LiveCode would be much slower than these compiled CLIs which handle, BTW, nearly all audio formats.

For example SoX needs three seconds for a spectrogram of 9 MByte mp3:

1. Make a new stack of size 660x400 and create an image
2. Make a folder containing a sound file test.mp3

Code: Select all

On MouseUp
   put </path/to/folder> into f
   put "test.mp3" into mp3
   -- there are a lot of other options, see man page of sox:
   get shell ("cd f; sox " & mp3 & " -n spectrogram -Y 360 -x 480")
   set filename of img 1 to empty -- needed for a refresh
   set filename of img 1 to f&"/spectrogram.png"
end MouseUp
[You can then also play the sound with SoX via open process ...]
The rest of the GUI (incl. controls) is best done with LiveCode.
shiftLock happens

bernd59
Posts: 10
Joined: Sat Nov 11, 2017 12:21 pm

Re: AudioWaveform

Post by bernd59 » Wed Feb 28, 2018 9:21 am

great!
that helps me a lot!
thanks!
Bernd

okk
Posts: 176
Joined: Wed Feb 04, 2015 11:37 am

Re: AudioWaveform

Post by okk » Sun Feb 02, 2020 1:51 pm

[-hh], thanks for the useful tip, I have looked for something like this for a while... I nevertheless cannot get your example working. I manage to create a spectrogram from within Terminal, but not from the Livecode Stack. I am working on MacOs X 10.12.6 with LC 9.5.
In Terminal I wrote: "/Users/oliver/Documents/development/waveform/sox /Users/oliver/Documents/development/waveform/test.aif -n spectrogram -Y 360 -x 480" and it works, but from within livecode it doesnt. Any tip?

I managed to get a simple file transformation to work from the LC stack:

Code: Select all

get shell ("/Users/oliver/Documents/development/waveform/sox /Users/oliver/Documents/development/waveform/test.aif /Users/oliver/Documents/development/waveform/testnew.wav")

Thanks
Oliver
Last edited by okk on Wed Feb 26, 2020 10:34 am, edited 2 times in total.

okk
Posts: 176
Joined: Wed Feb 04, 2015 11:37 am

Re: AudioWaveform

Post by okk » Sun Feb 02, 2020 10:42 pm

And a second question: I got the waveform generator that you mentioned in your post working on my computer. But how would this work in a standalone? I dont want that my users need to install audiowaveform and the required libraries. It wasn't the most smooth installtion anyway. Is it possible to copy all the needed files when creating the standalone? Thanks for any hint.
Oliver

Post Reply

Return to “Multimedia”