-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from flucoma/MelBands-reference
MelBands reference (RST and SC examples)
- Loading branch information
Showing
4 changed files
with
193 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,64 @@ | ||
|
||
STRONG::Use a buffer of MelBands to drive a bank of oscillators:: | ||
code:: | ||
// create some buffers | ||
( | ||
b = Buffer.read(s,FluidFilesPath("Nicol-LoopE-M.wav")); | ||
c = Buffer.new(s); | ||
~bells = Buffer.readChannel(s,FluidFilesPath("Tremblay-CF-ChurchBells.wav"),channels:[0]); | ||
~melBands = Buffer(s); | ||
~numBands = 100; | ||
) | ||
|
||
// run the process with basic parameters | ||
// listen to the original | ||
~bells.play; | ||
|
||
// analyse | ||
FluidBufMelBands.processBlocking(s,~bells,features:~melBands,numBands:~numBands,action:{"done".postln}); | ||
|
||
// playback | ||
( | ||
Routine{ | ||
t = Main.elapsedTime; | ||
FluidBufMelBands.process(s, b, features: c, numBands:10).wait; | ||
(Main.elapsedTime - t).postln; | ||
}.play | ||
x = { | ||
arg rate = 0.1, freqMul = 1, freqAdd = 0; | ||
var phs = Phasor.kr(0,rate,0,BufFrames.ir(~melBands)); | ||
var melBands = BufRd.kr(~numBands,~melBands,phs,1,4); | ||
var lowMel = 1127.010498 * ((20/700) + 1).log; // convert from hz to mels | ||
var highMel = 1127.010498 * ((20000/700) + 1).log; // convert from hz to mels | ||
var rangeMel = highMel - lowMel; | ||
var stepMel = rangeMel / (~numBands+1); | ||
var freqMel = Array.fill(~numBands,{arg i; (stepMel * (i+1)) + lowMel}); | ||
var freqHz = ((freqMel/ 1127.01048).exp - 1) * 700; // convert from mel to hz | ||
var sig = SinOsc.ar((freqHz * freqMul) + freqAdd,0,melBands); | ||
Splay.ar(sig) * 24.dbamp; | ||
}.play; | ||
) | ||
|
||
// listen to the source and look at the buffer | ||
b.play; | ||
c.plot | ||
:: | ||
|
||
STRONG::A stereo buffer example.:: | ||
CODE:: | ||
// manipulate the oscillator bank | ||
x.set(\rate,0.3); | ||
x.set(\rate,0.04); | ||
x.set(\freqMul,0.5); | ||
x.set(\freqAdd,-2000); | ||
|
||
// load two very different files | ||
:: | ||
STRONG::Look at the MelBands in FluidWaveform (as "features"):: | ||
code:: | ||
// create some buffers | ||
( | ||
b = Buffer.read(s,FluidFilesPath("Tremblay-SA-UprightPianoPedalWide.wav")); | ||
c = Buffer.read(s,FluidFilesPath("Tremblay-AaS-AcousticStrums-M.wav")); | ||
~src = Buffer.read(s,FluidFilesPath("Nicol-LoopE-M.wav")); | ||
~melBands = Buffer.new(s); | ||
) | ||
|
||
// composite one on left one on right as test signals | ||
FluidBufCompose.process(s, c, numFrames:b.numFrames, startFrame:555000,destStartChan:1, destination:b) | ||
b.play | ||
|
||
// create a buffer as destinations | ||
c = Buffer.new(s); | ||
// run the process with basic parameters | ||
FluidBufMelBands.processBlocking(s,~src,features:~melBands,action:{"done".postln}); | ||
|
||
//run the process on them | ||
// look at the mel bands as feature curves (a bit messy...) | ||
FluidWaveform(~src,featuresBuffer:~melBands,bounds:Rect(0,0,1600,400),stackFeatures:true,normalizeFeaturesIndependently:false); | ||
:: | ||
STRONG::Do a higher resolution analysis and plot it as an image in FluidWaveform:: | ||
code:: | ||
// create some buffers | ||
( | ||
Routine{ | ||
t = Main.elapsedTime; | ||
FluidBufMelBands.process(s, b, features: c, numBands:10).wait; | ||
(Main.elapsedTime - t).postln; | ||
}.play | ||
~src = Buffer.read(s,FluidFilesPath("Nicol-LoopE-M.wav")); | ||
~melBands = Buffer.new(s); | ||
) | ||
|
||
// look at the buffer: 10 bands for left, then 10 bands for right | ||
c.plot(separately:true) | ||
:: | ||
FluidBufMelBands.processBlocking(s,~src,features:~melBands,numBands:400,fftSize:4096,action:{"done".postln}); | ||
|
||
FluidWaveform(imageBuffer:~melBands,bounds:Rect(0,0,1600,400),imageColorScheme:1,imageColorScaling:1); | ||
:: |
Oops, something went wrong.