==============================================================================
| 16 | |
| 17 | //============================================================================== |
| 18 | ArcSpectrogram::ArcSpectrogram(Parameters& parameters) : juce::Thread("spectrogram thread"), mParameters(parameters) { |
| 19 | setFramesPerSecond(REFRESH_RATE_FPS); |
| 20 | mBuffers.fill(nullptr); |
| 21 | |
| 22 | // check if params has images, which would mean the plugin was reopened |
| 23 | if (!mParameters.ui.specComplete) { |
| 24 | // if not complete, we assume all images will be remade, no "half way" |
| 25 | // support currently |
| 26 | for (int i = 0; i < (int)ParamUI::SpecType::COUNT; i++) { |
| 27 | mImagesComplete[i] = false; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | mCloudLeft.images[CloudType::WAIT] = juce::PNGImageFormat::loadFrom(BinaryData::cloudLeftWait_png, BinaryData::cloudLeftWait_pngSize); |
| 32 | mCloudLeft.images[CloudType::SINGING] = juce::PNGImageFormat::loadFrom(BinaryData::cloudLeftSing_png, BinaryData::cloudLeftSing_pngSize); |
| 33 | mCloudLeft.images[CloudType::TOUCH] = juce::PNGImageFormat::loadFrom(BinaryData::cloudLeftTouch_png, BinaryData::cloudLeftTouch_pngSize); |
| 34 | mCloudRight.images[CloudType::WAIT] = juce::PNGImageFormat::loadFrom(BinaryData::cloudRightWait_png, BinaryData::cloudRightWait_pngSize); |
| 35 | mCloudRight.images[CloudType::SINGING] = juce::PNGImageFormat::loadFrom(BinaryData::cloudRightSing_png, BinaryData::cloudRightSing_pngSize); |
| 36 | mCloudRight.images[CloudType::TOUCH] = juce::PNGImageFormat::loadFrom(BinaryData::cloudRightTouch_png, BinaryData::cloudRightTouch_pngSize); |
| 37 | |
| 38 | // ComboBox is not zero indexed because 0 represents nothing selected |
| 39 | mSpecType.addItem("spectrogram", (int)ParamUI::SpecType::SPECTROGRAM + 1); |
| 40 | mSpecType.addItem("harmonic profile", (int)ParamUI::SpecType::HPCP + 1); |
| 41 | mSpecType.addItem("detected pitches", (int)ParamUI::SpecType::DETECTED + 1); |
| 42 | mSpecType.addItem("waveform", (int)ParamUI::SpecType::WAVEFORM + 1); |
| 43 | mSpecType.setTooltip("view different spectrum types"); |
| 44 | mSpecType.setJustificationType(juce::Justification::centred); |
| 45 | mSpecType.onChange = [this](void) { |
| 46 | // Will get called from user using UI ComboBox and from inside this class |
| 47 | // when loading buffers |
| 48 | mParameters.ui.specType = (ParamUI::SpecType)(mSpecType.getSelectedId() - 1); |
| 49 | }; |
| 50 | addAndMakeVisible(mSpecType); |
| 51 | |
| 52 | mActivePitchClass.reset(false); |
| 53 | |
| 54 | /*mParameters.note.onGrainCreated = [this](Utils::PitchClass pitchClass, int genIdx, float durationSec, float envGain) { |
| 55 | // always get the callback, but ignore it if note was released or over grain max |
| 56 | if (!mActivePitchClass[pitchClass] || mArcGrains.size() >= MAX_NUM_GRAINS) { |
| 57 | return; |
| 58 | } |
| 59 | ParamGenerator* gen = mParameters.note.notes[pitchClass]->generators[genIdx].get(); |
| 60 | float envIncSamples = Utils::ENV_LUT_SIZE / (durationSec * REFRESH_RATE_FPS); |
| 61 | mArcGrains.add(ArcGrain(gen, envGain, envIncSamples, pitchClass)); |
| 62 | }; */ |
| 63 | } |
| 64 | |
| 65 | ArcSpectrogram::~ArcSpectrogram() { |
| 66 | mParameters.note.onGrainCreated = nullptr; |