.cc - week five.
This week marks a bit of a breakthrough in terms of getting UI elements linked to SynthDefs. Thanks to Dave for helping me out. The program 'freezes' on Fast Fourier Transform frames and also the hop sizes can be altered. I also discovered an area of the FFT UGens - pack and unpack - which I may be able to use in relation to my research project on visual music. These UGens generate data related to an audio signal.
(
var fftBuf, sndBuf, chain,
path = ((PathName.new(Document.current.path)).pathOnly) ++"Samples/"; //PreGUI
// Buffer Creation - store FFT data
fftBuf = Buffer.alloc(
server: s,
numFrames: 2048,
numChannels: 1
);
// Place Sound into Buffer
sndBuf = Buffer.read(
server: s,
path: path++"houston.wav"
);
//Synth
SynthDef("AudioIce", { arg out=0, bufnum=0, soundBufnum=2, hopSize = 0.5, freeze = 0;
//freeze and hopSize to be effected by UI
var input, chain;
input = PlayBuf.ar(
1, //channels
soundBufnum, //buffer num
BufRateScale.kr(sndBuf), //rate
loop: 1);
chain = FFT(fftBuf, input, hop: hopSize);
chain = PV_MagFreeze(chain, freeze: freeze);
Out.ar(0, 0.5 * IFFT(chain).dup);
}).send(s);
//Make an instance:
~magFreeze = Synth("AudioIce", [\out, 0, \bufnum, fftBuf, \soundBufnum,sndBuf]);
)
(
//GUI
var w, b, line, titleBox;
w = GUI.window.new( "AudioIce", Rect( 128, 64, 180, 230 ));
w.view.decorator = FlowLayout( w.view.bounds );
w.view.background = Color( 0.0,0.714,0.96 );
titleBox = SCStaticText(
parent: w,
bounds: Rect(20, 100, 410, 65)
);
titleBox.stringColor_(Color.white);
titleBox.background_(Color(0.0,0.714,0.96));
titleBox.string_("Pausing effect:");
titleBox.font_(Font("Arial Black", 15));
SCButton(w, Rect(20,20,80,26))
.states_([["Freeze", Color.black, Color.white]])
.mouseDownAction_({ |freeze|
~magFreeze.set(\freeze, 1);
})
.mouseUpAction_({ |freeze|
~magFreeze.set(\freeze, 0);
});
titleBox = SCStaticText(
parent: w,
bounds: Rect(20, 100, 410, 65)
);
titleBox.stringColor_(Color.white);
titleBox.background_(Color(0.0,0.714,0.96));
titleBox.string_("FFT Windowsize:");
titleBox.font_(Font("Arial Black", 15));
a = SCSlider(w, Rect(20, 80, 100, 40))
.focusColor_(Color.white)
.action_({|hopSize|
~magFreeze.set(\hopSize, a.value);
});
w.front;
)
MagFFT.rtf | houstonnnnnnn.mp3 (804 kB)
.sources.
Haines, Christian 28.08.08, “FFT (1),” Lecture of EMU, Adelaide University.
iieiwrmeieweeiimeemmwreiweremweireeemeimwieewwrwweereireeiimeewmiwwwemwiewimeeeremeiewmemweewieewerwemwiimiewmeiwireiiwrrewmwewree |
3.9.08
copywrite 3:55 pm
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment