2024-08-10 19:26:56 +00:00
# pragma once
2024-09-12 22:09:54 +00:00
# define VERSION_HINT 2
2024-08-10 19:26:56 +00:00
# include <JuceHeader.h>
2024-11-06 20:15:09 +00:00
# include "../components/EffectComponent.h"
# include "../components/SvgButton.h"
2024-08-13 13:55:30 +00:00
# include "../LookAndFeel.h"
2024-11-06 20:15:09 +00:00
# include "../components/SwitchButton.h"
2024-11-09 22:51:42 +00:00
# include "../audio/SmoothEffect.h"
2024-08-10 19:26:56 +00:00
2024-09-12 22:09:54 +00:00
class VisualiserParameters {
public :
2024-11-17 12:18:30 +00:00
BooleanParameter * graticuleEnabled = new BooleanParameter ( " Show Graticule " , " graticuleEnabled " , VERSION_HINT , false , " Show the graticule or grid lines over the oscilloscope display. " ) ;
BooleanParameter * smudgesEnabled = new BooleanParameter ( " Show Smudges " , " smudgesEnabled " , VERSION_HINT , false , " Adds a subtle layer of dirt/smudges to the oscilloscope display to make it look more realistic. " ) ;
BooleanParameter * upsamplingEnabled = new BooleanParameter ( " Upsample Audio " , " upsamplingEnabled " , VERSION_HINT , true , " Upsamples the audio before visualising it to make it appear more realistic, at the expense of performance. " ) ;
BooleanParameter * sweepEnabled = new BooleanParameter ( " Sweep " , " sweepEnabled " , VERSION_HINT , false , " Plots the audio signal over time, sweeping from left to right " ) ;
2024-09-12 22:09:54 +00:00
BooleanParameter * visualiserFullScreen = new BooleanParameter ( " Visualiser Fullscreen " , " visualiserFullScreen " , VERSION_HINT , false , " Makes the software visualiser fullscreen. " ) ;
std : : shared_ptr < Effect > persistenceEffect = std : : make_shared < Effect > (
new EffectParameter (
" Persistence " ,
" Controls how long the light glows for on the oscilloscope display. " ,
" persistence " ,
VERSION_HINT , 0.5 , 0 , 6.0
)
) ;
std : : shared_ptr < Effect > hueEffect = std : : make_shared < Effect > (
new EffectParameter (
" Hue " ,
" Controls the hue/colour of the oscilloscope display. " ,
" hue " ,
VERSION_HINT , 125 , 0 , 359 , 1
)
) ;
std : : shared_ptr < Effect > brightnessEffect = std : : make_shared < Effect > (
new EffectParameter (
" Brightness " ,
" Controls how bright the light glows for on the oscilloscope display. " ,
" brightness " ,
2024-11-09 22:51:42 +00:00
VERSION_HINT , 2.0 , 0.0 , 10.0
2024-09-12 22:09:54 +00:00
)
) ;
std : : shared_ptr < Effect > intensityEffect = std : : make_shared < Effect > (
new EffectParameter (
" Intensity " ,
" Controls how bright the electron beam of the oscilloscope is. " ,
" intensity " ,
2024-11-17 12:18:30 +00:00
VERSION_HINT , 5.0 , 0.0 , 10.0
2024-09-12 22:09:54 +00:00
)
) ;
2024-09-29 18:46:35 +00:00
std : : shared_ptr < Effect > saturationEffect = std : : make_shared < Effect > (
new EffectParameter (
" Saturation " ,
" Controls how saturated the colours are on the oscilloscope. " ,
" saturation " ,
VERSION_HINT , 1.0 , 0.0 , 5.0
)
) ;
2024-09-29 19:36:16 +00:00
std : : shared_ptr < Effect > focusEffect = std : : make_shared < Effect > (
new EffectParameter (
" Focus " ,
" Controls how focused the electron beam of the oscilloscope is. " ,
" focus " ,
VERSION_HINT , 1.0 , 0.01 , 10.0
)
) ;
2024-11-06 20:15:09 +00:00
std : : shared_ptr < Effect > noiseEffect = std : : make_shared < Effect > (
new EffectParameter (
" Noise " ,
" Controls how much noise/grain is added to the oscilloscope display. " ,
" noise " ,
2024-11-17 12:18:30 +00:00
VERSION_HINT , 0.0 , 0.0 , 1.0
2024-11-06 20:15:09 +00:00
)
) ;
2024-11-09 21:37:20 +00:00
std : : shared_ptr < Effect > glowEffect = std : : make_shared < Effect > (
new EffectParameter (
" Glow " ,
" Controls how much the light glows on the oscilloscope display. " ,
" glow " ,
VERSION_HINT , 0.3 , 0.0 , 1.0
)
) ;
2024-11-09 22:51:42 +00:00
std : : shared_ptr < Effect > smoothEffect = std : : make_shared < Effect > (
std : : make_shared < SmoothEffect > ( ) ,
new EffectParameter (
" Smoothing " ,
" This works as a low-pass frequency filter, effectively reducing the sample rate of the audio being visualised. " ,
" visualiserSmoothing " ,
VERSION_HINT , 0 , 0.0 , 1.0
)
) ;
2024-11-17 12:18:30 +00:00
std : : shared_ptr < Effect > sweepMsEffect = std : : make_shared < Effect > (
new EffectParameter (
" Sweep (ms) " ,
" The number of milliseconds it takes for the oscilloscope to sweep from left to right. " ,
" sweepMs " ,
VERSION_HINT , 0.3 , 0.0 , 1.0
)
) ;
2024-11-09 22:51:42 +00:00
2024-11-17 12:18:30 +00:00
std : : vector < std : : shared_ptr < Effect > > effects = { persistenceEffect , hueEffect , brightnessEffect , intensityEffect , saturationEffect , focusEffect , noiseEffect , glowEffect , sweepMsEffect } ;
2024-11-09 22:51:42 +00:00
std : : vector < BooleanParameter * > booleans = { graticuleEnabled , smudgesEnabled , upsamplingEnabled , visualiserFullScreen , sweepEnabled } ;
2024-09-12 22:09:54 +00:00
} ;
2024-08-10 19:26:56 +00:00
class VisualiserSettings : public juce : : Component {
public :
2024-09-22 17:49:58 +00:00
VisualiserSettings ( VisualiserParameters & , int numChannels = 2 ) ;
2024-08-10 19:26:56 +00:00
~ VisualiserSettings ( ) ;
void resized ( ) override ;
2024-10-22 21:25:09 +00:00
double getBrightness ( ) {
return parameters . brightnessEffect - > getActualValue ( ) - 2 ;
}
double getIntensity ( ) {
return parameters . intensityEffect - > getActualValue ( ) / 100 ;
}
double getPersistence ( ) {
return parameters . persistenceEffect - > getActualValue ( ) - 1.33 ;
}
double getHue ( ) {
return parameters . hueEffect - > getActualValue ( ) ;
}
double getSaturation ( ) {
return parameters . saturationEffect - > getActualValue ( ) ;
}
double getFocus ( ) {
return parameters . focusEffect - > getActualValue ( ) / 100 ;
}
2024-11-06 20:15:09 +00:00
double getNoise ( ) {
return parameters . noiseEffect - > getActualValue ( ) ;
}
2024-11-09 21:37:20 +00:00
double getGlow ( ) {
return parameters . glowEffect - > getActualValue ( ) * 3 ;
}
2024-10-22 21:25:09 +00:00
bool getGraticuleEnabled ( ) {
return parameters . graticuleEnabled - > getBoolValue ( ) ;
}
bool getSmudgesEnabled ( ) {
return parameters . smudgesEnabled - > getBoolValue ( ) ;
}
bool getUpsamplingEnabled ( ) {
return parameters . upsamplingEnabled - > getBoolValue ( ) ;
}
2024-08-10 19:26:56 +00:00
2024-09-12 22:09:54 +00:00
VisualiserParameters & parameters ;
2024-09-22 17:49:58 +00:00
int numChannels ;
2024-09-12 22:09:54 +00:00
private :
EffectComponent brightness { * parameters . brightnessEffect } ;
EffectComponent intensity { * parameters . intensityEffect } ;
EffectComponent persistence { * parameters . persistenceEffect } ;
EffectComponent hue { * parameters . hueEffect } ;
2024-09-29 18:46:35 +00:00
EffectComponent saturation { * parameters . saturationEffect } ;
2024-09-29 19:36:16 +00:00
EffectComponent focus { * parameters . focusEffect } ;
2024-11-09 21:37:20 +00:00
EffectComponent noise { * parameters . noiseEffect } ;
EffectComponent glow { * parameters . glowEffect } ;
2024-11-09 22:51:42 +00:00
EffectComponent smooth { * parameters . smoothEffect } ;
2024-11-17 12:18:30 +00:00
EffectComponent sweepMs { * parameters . sweepMsEffect } ;
2024-08-13 13:55:30 +00:00
2024-09-12 22:09:54 +00:00
jux : : SwitchButton graticuleToggle { parameters . graticuleEnabled } ;
jux : : SwitchButton smudgeToggle { parameters . smudgesEnabled } ;
jux : : SwitchButton upsamplingToggle { parameters . upsamplingEnabled } ;
2024-11-17 12:18:30 +00:00
jux : : SwitchButton sweepToggle { parameters . sweepEnabled } ;
2024-08-10 19:26:56 +00:00
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR ( VisualiserSettings )
} ;
2024-08-13 13:55:30 +00:00
class SettingsWindow : public juce : : DocumentWindow {
public :
SettingsWindow ( juce : : String name ) : juce : : DocumentWindow ( name , Colours : : darker , juce : : DocumentWindow : : TitleBarButtons : : closeButton ) { }
void closeButtonPressed ( ) override {
setVisible ( false ) ;
}
} ;