Page 1 of 1

AudioWaveform

Posted: Sun Feb 25, 2018 4:14 pm
by bernd59
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

Re: AudioWaveform

Posted: Tue Feb 27, 2018 5:27 pm
by [-hh]
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

Re: AudioWaveform

Posted: Wed Feb 28, 2018 7:05 am
by bernd59
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

Re: AudioWaveform

Posted: Wed Feb 28, 2018 8:29 am
by [-hh]
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.

Re: AudioWaveform

Posted: Wed Feb 28, 2018 9:21 am
by bernd59
great!
that helps me a lot!
thanks!
Bernd

Re: AudioWaveform

Posted: Sun Feb 02, 2020 1:51 pm
by okk
[-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

Re: AudioWaveform

Posted: Sun Feb 02, 2020 10:42 pm
by okk
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