|
|
|
@ -16,12 +16,12 @@ FluidWaveform : FluidViewer {
|
|
|
|
var <win;
|
|
|
|
var <win;
|
|
|
|
|
|
|
|
|
|
|
|
*new {
|
|
|
|
*new {
|
|
|
|
arg audioBuffer, slicesBuffer, featureBuffer, bounds, lineWidth = 1, waveformColor, stackFeatures = false;
|
|
|
|
arg audioBuffer, slicesBuffer, featureBuffer, bounds, lineWidth = 1, waveformColor, stackFeatures = false, spectrogram = false;
|
|
|
|
^super.new.init(audioBuffer,slicesBuffer, featureBuffer, bounds, lineWidth, waveformColor,stackFeatures);
|
|
|
|
^super.new.init(audioBuffer,slicesBuffer, featureBuffer, bounds, lineWidth, waveformColor,stackFeatures,spectrogram);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
init {
|
|
|
|
arg audio_buf, slices_buf, feature_buf, bounds, lineWidth, waveformColor,stackFeatures = false;
|
|
|
|
arg audio_buf, slices_buf, feature_buf, bounds, lineWidth, waveformColor,stackFeatures = false, spectrogram = false;
|
|
|
|
Task{
|
|
|
|
Task{
|
|
|
|
var sfv, categoryCounter = 0;
|
|
|
|
var sfv, categoryCounter = 0;
|
|
|
|
|
|
|
|
|
|
|
|
@ -34,6 +34,43 @@ FluidWaveform : FluidViewer {
|
|
|
|
win.background_(Color.white);
|
|
|
|
win.background_(Color.white);
|
|
|
|
|
|
|
|
|
|
|
|
if(audio_buf.notNil,{
|
|
|
|
if(audio_buf.notNil,{
|
|
|
|
|
|
|
|
if(spectrogram,{
|
|
|
|
|
|
|
|
var magsbuf = Buffer(audio_buf.server);
|
|
|
|
|
|
|
|
var condition = Condition.new;
|
|
|
|
|
|
|
|
var colors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(File.exists("/Users/macprocomputer/Desktop/_flucoma/code/flucoma-sc/test/CETperceptual_csv_0_1/CET-L16.csv").not,{
|
|
|
|
|
|
|
|
"Sorry, colors file doesn't exist...... where can I put this file so it exists for everyone!!!?!?!?!?!?".warn;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
colors = CSVFileReader.readInterpret("/Users/macprocomputer/Desktop/_flucoma/code/flucoma-sc/test/CETperceptual_csv_0_1/CET-L16.csv").collect{
|
|
|
|
|
|
|
|
arg row;
|
|
|
|
|
|
|
|
Color.fromArray(row);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FluidBufSTFT.processBlocking(audio_buf.server,audio_buf,magnitude:magsbuf,action:{
|
|
|
|
|
|
|
|
magsbuf.loadToFloatArray(action:{
|
|
|
|
|
|
|
|
arg mags;
|
|
|
|
|
|
|
|
fork({
|
|
|
|
|
|
|
|
var img = Image(magsbuf.numFrames,magsbuf.numChannels);
|
|
|
|
|
|
|
|
mags = (mags / mags.maxItem).ampdb.linlin(-120.0,0.0,0,255).asInteger;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mags.do{
|
|
|
|
|
|
|
|
arg mag, index;
|
|
|
|
|
|
|
|
img.setColor(colors[mag], index.div(magsbuf.numChannels), magsbuf.numChannels - 1 - index.mod(magsbuf.numChannels));
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UserView(win,Rect(0,0,win.bounds.width,win.bounds.height))
|
|
|
|
|
|
|
|
.drawFunc_{
|
|
|
|
|
|
|
|
img.drawInRect(Rect(0,0,win.bounds.width,win.bounds.height));
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
condition.unhang;
|
|
|
|
|
|
|
|
},AppClock)
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
condition.hang;
|
|
|
|
|
|
|
|
},{
|
|
|
|
var path = "%%_%_FluidWaveform.wav".format(PathName.tmp,Date.localtime.stamp,UniqueID.next);
|
|
|
|
var path = "%%_%_FluidWaveform.wav".format(PathName.tmp,Date.localtime.stamp,UniqueID.next);
|
|
|
|
|
|
|
|
|
|
|
|
audio_buf.write(path,"wav");
|
|
|
|
audio_buf.write(path,"wav");
|
|
|
|
@ -50,6 +87,7 @@ FluidWaveform : FluidViewer {
|
|
|
|
|
|
|
|
|
|
|
|
File.delete(path);
|
|
|
|
File.delete(path);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if(slices_buf.notNil,{
|
|
|
|
if(slices_buf.notNil,{
|
|
|
|
slices_buf.numChannels.switch(
|
|
|
|
slices_buf.numChannels.switch(
|
|
|
|
|