added more color schemes to choose from, also new grey scale

nix
Ted Moore 4 years ago
parent 7c395f7929
commit 8c02efd601

@ -25,6 +25,14 @@ FluidWaveform : FluidViewer {
win.close; win.close;
} }
loadColorFile {
arg filename;
^CSVFileReader.readInterpret(FluidFilesPath("../Resources/color-schemes/%.csv".format(filename))).collect{
arg row;
Color.fromArray(row);
}
}
init { init {
arg audio_buf, slices_buf, feature_buf, parent_, bounds, lineWidth, waveformColor,stackFeatures = false, showSpectrogram = false, spectrogramColorScheme = 0, spectrogramAlpha = 1, showWaveform = true,normalizeFeaturesIndependently = true; arg audio_buf, slices_buf, feature_buf, parent_, bounds, lineWidth, waveformColor,stackFeatures = false, showSpectrogram = false, spectrogramColorScheme = 0, spectrogramAlpha = 1, showWaveform = true,normalizeFeaturesIndependently = true;
Task{ Task{
@ -59,19 +67,24 @@ FluidWaveform : FluidViewer {
var condition = Condition.new; var condition = Condition.new;
var colors; var colors;
// TODO: no need for this to be a switch statement.
spectrogramColorScheme.switch( spectrogramColorScheme.switch(
0,{ 0,{
colors = 256.collect{ colors = this.loadColorFile("CET-L02");
arg i;
Color.gray(i / 255.0);
};
}, },
1,{ 1,{
colors = CSVFileReader.readInterpret(FluidFilesPath("../Resources/color-schemes/CET-L16.csv")).collect{ colors = this.loadColorFile("CET-L16");
arg row; },
Color.fromArray(row); 2,{
}; colors = this.loadColorFile("CET-L08");
},{ },
3,{
colors = this.loadColorFile("CET-L03");
},
4,{
colors = this.loadColorFile("CET-L04");
},
{
"% spectrogramColorScheme: % is not valid.".format(thisMethod,spectrogramColorScheme).warn; "% spectrogramColorScheme: % is not valid.".format(thisMethod,spectrogramColorScheme).warn;
} }
); );

@ -39,10 +39,13 @@ ARGUMENT:: showSpectrogram
Boolean whether or not to plot a spectrogram. The default is STRONG::false::. Boolean whether or not to plot a spectrogram. The default is STRONG::false::.
ARGUMENT:: spectrogramColorScheme ARGUMENT:: spectrogramColorScheme
An integer indicating which color scheme footnote::The non-gray-scale color schemes used are from https://colorcet.com/ Kovesi, Peter. "Good colour maps: How to design them." arXiv preprint arXiv:1509.03700 (2015). https://arxiv.org/abs/1509.03700 :: to use to distinguish magitudes in the spectrogram. The default is 0. An integer indicating which color scheme footnote::The color schemes used are from https://colorcet.com/ Kovesi, Peter. "Good colour maps: How to design them." arXiv preprint arXiv:1509.03700 (2015). https://arxiv.org/abs/1509.03700 :: to use to distinguish magitudes in the spectrogram. The default is 0.
table:: table::
## 0 || Gray-scale ## 0 || Grey scale with slightly reduced contrast to avoid display saturation problems
## 1 || Black - Blue - Green - Yellow - White ## 1 || Black - Blue - Green - Yellow - White
## 2 || Blue - Magenta - Yellow highly saturated
## 3 || Black - Red - Yellow - White
## 4 || Black - Red - Yellow
:: ::
ARGUMENT:: spectrogramAlpha ARGUMENT:: spectrogramAlpha
@ -94,6 +97,18 @@ w.front;
// show spectrogram // show spectrogram
FluidWaveform(~drums,bounds:Rect(0,0,1200,300),showSpectrogram:true); FluidWaveform(~drums,bounds:Rect(0,0,1200,300),showSpectrogram:true);
// more colors
FluidWaveform(~drums,bounds:Rect(0,0,1200,300),showSpectrogram:true,spectrogramColorScheme:1);
// more colors
FluidWaveform(~drums,bounds:Rect(0,0,1200,300),showSpectrogram:true,spectrogramColorScheme:2);
// more colors
FluidWaveform(~drums,bounds:Rect(0,0,1200,300),showSpectrogram:true,spectrogramColorScheme:3);
// more colors
FluidWaveform(~drums,bounds:Rect(0,0,1200,300),showSpectrogram:true,spectrogramColorScheme:4);
// put in that another window // put in that another window
( (
w = Window("FluidWaveform Test",Rect(0,0,1000,600)); w = Window("FluidWaveform Test",Rect(0,0,1000,600));

Loading…
Cancel
Save