command line audio tools

For everything that's not in any way related to PureBasic. General chat etc...
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

command line audio tools

Post by blueznl »

with all these experts hanging around here... :-)

looking for some command line utils to mess around with audio files (notably wav 8 khz phone recordings) and i'm looking for 'effects', a 'normalizer' and something that mixes two audio files...

(got sox and vocoder, but what else?)

any suggestions welcome (yeah, it's on a windows box(

(and a second yeah, i know i can do a lot with purebasic, but haven't done anything with audiofiles yet... although some persuasion in that direction might provide an adequate incentive... ten times word value in boardscript aka. scrabble)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

It's easy to make a volume-change on your own. It's just reading a Word-Value (at 16 Bit-Sound), multiplying it with the amp-factor and writing it back. (Be careful, 8-Bit-sound is handled as unsigened (zero-line at 128), all others signed)
For normalization you first scan for the highest amplitude ( abs(PeekW()) ), then get the volumechange-factor by Pow(2, Bits) / abs(maxvalue) and do a volumechange with this one.

stereo is nothing more than a 2 seperate tracks in one file. You always have to calculate left with left and right with right values.

To mix 2 Tracks together just add their values sample by sample and divide the result by 2 (that is ~ -6dB).

So now you can make your own Delay - just add a sound volume-lowered to itself with an offset.

A chorus is nearly the same as a delay, but the offset is only about 1 ms.

Even a reverb is possible in this way.

Doing a compressor is a bit more complicated, because you have to handle the attack/decay-volumechanges on your own, but possible, too.

All these effects to not modify the frequence-spectrum. For that you'll need FFT or IIR/FIR and this stuff (I do not know).

Here you'll find a very good description of the WAV-format:
http://www.sonicspot.com/guide/wavefiles.html
You'll need it to get the information of how to interpretate the sampledata.
%1>>1+1*1/1-1!1|1&1<<$1=1
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Froggerprogger wrote:For normalization you first scan for the highest amplitude ( abs(PeekW()) ), then get the volumechange-factor by Pow(2, Bits) / abs(maxvalue) and do a volumechange with this one.
Very good explanation: simple and clear!!

About normalization:

I think there is another ways with best results. Per example calculating the 'distance' betwen each value and the peek and then amplifiying it according to this factor.

Then you amplify more lower parts volume and not only push up all the values with the same percent.
ARGENTINA WORLD CHAMPION
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

http://DSPguru.doom9.net/

This program uses DLL's from other to Demux and Re-encode AUDIO into any format you can think off...

And for free :P
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

@ricardo
If you would change each samplevalue by an individual factor (e.g. depending on the difference of the peak and the actual samplevalue), you would change the shape of the wave.
A pure sine-wave would become more like a rect-shape, because the more silent samples are increased a lot, the more loud samples just a bit.
Modifiing the shape results in modifiing the frequencies, so perhaps you would create a cool effect, but no clean normalization.

For a "normalization" where the louder parts are increased only a bit, and the silent ones more intensive you would have to specify the loudness in a time-frame of e.g. 100-1000 ms. and in/decrease the actual volume-factor by the average loudness of this time-frame. The changes of the volume-factor itself must not work immediately, but with an attack/decay-speed of e.g. 20+ ms.
Further the whole algorithm could (if you want) start only if the average volume lies under a defined treshhold-value.
This is the concept of an expander - it's working just the other way round than a compressor.

I cannot imagine any other concept for 'normalization' than simply changing the volume of your whole sound depending on the maximum value inside it, but perhaps (ALWAYS ANYTHING is 'perhaps' - fu**ing chaos-theory :D ) I'm wrong.

@blueznl
Using fmod for this really makes fun (if you have the time for it).
You can access the actual bufferdata in realtime through a callback-procedure. Inside your procedure you can do anything with the sampledata (stereo 16-Bit integer) Or you could create your own sampledata for creating sounds.

@Num3
It ENcodes AC3 for free ?? cool!
%1>>1+1*1/1-1!1|1&1<<$1=1
ricardo
Addict
Addict
Posts: 2438
Joined: Fri Apr 25, 2003 7:06 pm
Location: Argentina

Post by ricardo »

Froggerprogger wrote:@ricardo
If you would change each samplevalue by an individual factor (e.g. depending on the difference of the peak and the actual samplevalue), you would change the shape of the wave.
A pure sine-wave would become more like a rect-shape, because the more silent samples are increased a lot, the more loud samples just a bit.
Modifiing the shape results in modifiing the frequencies, so perhaps you would create a cool effect, but no clean normalization.
My own experience teach me that its possible and the results are great.
Of course the algo must be carefully designed to avoid some horrible result, but when you find the solution, the results are good ones.
ARGENTINA WORLD CHAMPION
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

you are basically building a compander i guess :-)

but euhm, the reason for asking is i wasn't looking for programming this stuff myself, just needed some to do some quick thingies...

wasn't into writing me own wav headers yet... no standard purebasic commands for writing, or did i overlook them? perhaps an api...
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Post Reply