void FilterGraph::setLastDocumentOpened (const File& file) { RecentlyOpenedFilesList recentFiles; recentFiles.restoreFromString (getAppProperties().getUserSettings() ->getValue ("recentFilterGraphFiles")); recentFiles.addFile (file); getAppProperties().getUserSettings() ->setValue ("recentFilterGraphFiles", recentFiles.toString()); }
PMixAudioEngine::PMixAudioEngine() : doc(*this) , faustDSPFormat(doc.getLibraryPath(), File(FAUST_DRAW_PATH)) { Logger::setCurrentLogger(&logger); LOG("pMix v 0.01"); // initialise our settings file.. PropertiesFile::Options options; options.applicationName = "pMix"; options.filenameSuffix = "settings"; options.osxLibrarySubFolder = "Application Support"; #ifdef JUCE_MAC options.folderName = "pMix2"; #endif appProperties = new ApplicationProperties(); appProperties->setStorageParameters (options); formatManager.addDefaultFormats(); formatManager.addFormat (new InternalPluginFormat()); InternalPluginFormat internalFormat; internalFormat.getAllTypes (internalTypes); ScopedPointer<XmlElement> savedPluginList (getAppProperties().getUserSettings()->getXmlValue ("pluginList")); if (savedPluginList != nullptr) knownPluginList.recreateFromXml (*savedPluginList); ScopedPointer<PluginDirectoryScanner> scanner = new PluginDirectoryScanner(knownFaustDSPList, faustDSPFormat, faustDSPFormat.getDefaultLocationsToSearch(), true, File::nonexistent); LOG("Scanning Faust .dsp files..."); String pluginBeingScanned; while (scanner->scanNextFile(true, pluginBeingScanned)) { } String str(knownFaustDSPList.getNumTypes()); //LOG("found " + str + " faust .dsp files"); pluginSortMethod = (KnownPluginList::SortMethod) getAppProperties().getUserSettings()->getIntValue ("pluginSortMethod", KnownPluginList::sortByFileSystemLocation); setPluginSortMethod(pluginSortMethod); #if JUCE_MAC knownPluginList.addToBlacklist("/Library/Audio/Plug-Ins/VST/pMixPlugin.vst"); #endif knownPluginList.addChangeListener (this); }
void PMixAudioEngine::changeListenerCallback (ChangeBroadcaster* broadcaster) { if (broadcaster == &knownPluginList) { // save the plugin list every time it gets chnaged, so that if we're scanning // and it crashes, we've still saved the previous ones ScopedPointer<XmlElement> savedPluginList (knownPluginList.createXml()); if (savedPluginList != nullptr) { getAppProperties().getUserSettings()->setValue ("pluginList", savedPluginList); getAppProperties().saveIfNeeded(); } } }
void handleAsyncUpdate() override { File fileToOpen; for (int i = 0; i < getCommandLineParameterArray().size(); ++i) { fileToOpen = File::getCurrentWorkingDirectory().getChildFile (getCommandLineParameterArray()[i]); if (fileToOpen.existsAsFile()) break; } if (! fileToOpen.existsAsFile()) { RecentlyOpenedFilesList recentFiles; recentFiles.restoreFromString (getAppProperties().getUserSettings()->getValue ("recentFilterGraphFiles")); if (recentFiles.getNumFiles() > 0) fileToOpen = recentFiles.getFile (0); } if (fileToOpen.existsAsFile()) if (GraphDocumentComponent* graph = mainWindow->getGraphEditor()) graph->graph.loadFrom (fileToOpen, true); }
File FilterGraph::getLastDocumentOpened() { RecentlyOpenedFilesList recentFiles; recentFiles.restoreFromString (getAppProperties().getUserSettings() ->getValue ("recentFilterGraphFiles")); return recentFiles.getFile (0); }
PluginListWindow (MainHostWindow& owner_, AudioPluginFormatManager& formatManager) : DocumentWindow ("Available Plugins", Colours::white, DocumentWindow::minimiseButton | DocumentWindow::closeButton), owner (owner_) { const File deadMansPedalFile (getAppProperties().getUserSettings() ->getFile().getSiblingFile ("RecentlyCrashedPluginsList")); setContentOwned (new PluginListComponent (formatManager, owner.knownPluginList, deadMansPedalFile, getAppProperties().getUserSettings()), true); setResizable (true, false); setResizeLimits (300, 400, 800, 1500); setTopLeftPosition (60, 60); restoreWindowStateFromString (getAppProperties().getUserSettings()->getValue ("listWindowPos")); setVisible (true); }
void PMixAudioEngine::setPluginSortMethod(KnownPluginList::SortMethod sortMethod) { pluginSortMethod = sortMethod; getAppProperties().getUserSettings()->setValue ("pluginSortMethod", (int) pluginSortMethod); }
~PluginListWindow() { getAppProperties().getUserSettings()->setValue ("listWindowPos", getWindowStateAsString()); clearContentComponent(); }
void MainContentComponent::buttonClicked (Button* buttonThatWasClicked) { //[UserbuttonClicked_Pre] //[/UserbuttonClicked_Pre] if (buttonThatWasClicked == convButton) { //[UserButtonCode_convButton] -- add your button handler code here.. const ScopedLock fl(soundListLock); setPlayheadUiEnabled(false); bool convValid = true; float q; float s; double nfft; { const ScopedLock pl(paramLock); q = qParam; s = sParam; nfft = static_cast<double>(nfftParam); } int fftInputLen = static_cast<int>(std::pow(2.0, nfft)); int fftOutputLen = fftInputLen / 2 + 1; int numChannels = 1; unordered_set<int> includedSounds; int maxChannels = 0; float pSum = 0.0f; float rSum = 0.0f; for (const auto& iter : idToSound) { int id = iter.first; Sound* sound = iter.second.get(); int numChannels = sound->getBufferNumChannels(); if (sound->isIncluded() && numChannels > 0) { maxChannels = numChannels > maxChannels ? numChannels : maxChannels; includedSounds.emplace(id); pSum += static_cast<float>(sound->getPValue()); rSum += static_cast<float>(sound->getRValue()); } } float n = static_cast<float>(includedSounds.size()); float pScale = n * q / pSum; float rScale = n * s / rSum; if (maxChannels == 0) { return; } kiss_fftr_state* fftInverseState = kiss_fftr_alloc(fftInputLen, 1, nullptr, nullptr); kiss_fft_cpx* CONV = static_cast<kiss_fft_cpx*>(calloc(fftOutputLen * maxChannels, sizeof(kiss_fft_cpx))); conv.setSize(maxChannels, fftInputLen); float max = -1.0f; // convolve for (int convChannel = 0; convChannel < maxChannels; ++convChannel) { kiss_fft_cpx* CONVCHANNEL = CONV + (convChannel * fftOutputLen); bool isFirstSound = true; for (const auto& id : includedSounds) { Sound* sound = idToSound[id].get(); jassert(sound != nullptr); float p = pScale * static_cast<float>(sound->getPValue()); float r = rScale * static_cast<float>(sound->getRValue()); int soundNumChannels = sound->getBufferNumChannels(); int soundNumSamples = sound->getBufferNumSamples(); int soundChannel = convChannel >= soundNumChannels ? soundNumChannels - 1 : convChannel; const kiss_fft_cpx* SOUNDCHANNEL = sound->getSpectra(fftInputLen, soundChannel); for (int i = 0; i < fftOutputLen; ++i) { float xr = SOUNDCHANNEL[i].r; float xi = SOUNDCHANNEL[i].i; float xMag = sqrtf((xr * xr) + (xi * xi)); float xPhs = atan2f(xi, xr); float convMag = powf(xMag, p); float convPhs = r * xPhs; float convr = convMag * cosf(convPhs); float convi = convMag * sinf(convPhs); if (std::isnan(convr) || std::isnan(convi)) { convValid = false; } if (isFirstSound) { CONVCHANNEL[i].r = convr; CONVCHANNEL[i].i = convi; } else { float a = CONVCHANNEL[i].r; float b = CONVCHANNEL[i].i; float c = convr; float d = convi; CONVCHANNEL[i].r = a * c - b * d; CONVCHANNEL[i].i = a * d + b * c; } } isFirstSound = false; } // ifft kiss_fftri(fftInverseState, CONVCHANNEL, conv.getWritePointer(convChannel)); // check max float channelMax = conv.findMinMax(convChannel, 0, fftInputLen).getEnd(); max = channelMax > max ? channelMax : max; } delete fftInverseState; delete CONV; // normalize conv.applyGain(1.0f / max); if (!convValid) { AlertWindow::showMessageBoxAsync(AlertWindow::WarningIcon, "Error", "Parameters produced NaN value."); return; } setPlayheadAudio(&conv); //[/UserButtonCode_convButton] } else if (buttonThatWasClicked == settingsButton) { //[UserButtonCode_settingsButton] -- add your button handler code here.. AudioDeviceSelectorComponent audioSettingsComp(deviceManager, 0, 256, 0, 256, true, true, true, false); audioSettingsComp.setSize(500, 450); DialogWindow::LaunchOptions o; o.content.setNonOwned(&audioSettingsComp); o.dialogTitle = "Audio Settings"; o.componentToCentreAround = this; o.dialogBackgroundColour = Colours::azure; o.escapeKeyTriggersCloseButton = true; o.useNativeTitleBar = false; o.resizable = false; o.runModal(); ScopedPointer<XmlElement> audioState(deviceManager.createStateXml()); getAppProperties().getUserSettings()->setValue("audioDeviceState", audioState); getAppProperties().getUserSettings()->saveIfNeeded(); //[/UserButtonCode_settingsButton] } else if (buttonThatWasClicked == playButton) { //[UserButtonCode_playButton] -- add your button handler code here.. const ScopedLock pal(playheadAudioLock); playheadState = PlayheadState::playing; playheadAudioSamplesCompleted = 0; //[/UserButtonCode_playButton] } else if (buttonThatWasClicked == loopButton) { //[UserButtonCode_loopButton] -- add your button handler code here.. const ScopedLock pal(playheadAudioLock); playheadState = PlayheadState::looping; //[/UserButtonCode_loopButton] } else if (buttonThatWasClicked == stopButton) { //[UserButtonCode_stopButton] -- add your button handler code here.. const ScopedLock pal(playheadAudioLock); playheadState = PlayheadState::stopped; playheadAudioSamplesCompleted = 0; //[/UserButtonCode_stopButton] } else if (buttonThatWasClicked == qDefaultButton) { //[UserButtonCode_qDefaultButton] -- add your button handler code here.. qSlider->setValue(1.0); //[/UserButtonCode_qDefaultButton] } else if (buttonThatWasClicked == sDefaultButton) { //[UserButtonCode_sDefaultButton] -- add your button handler code here.. sSlider->setValue(1.0); //[/UserButtonCode_sDefaultButton] } else if (buttonThatWasClicked == saveButton) { //[UserButtonCode_saveButton] -- add your button handler code here.. const ScopedLock pal(playheadAudioLock); if (playheadAudio.getNumChannels() > 0 && playheadAudio.getNumSamples() > 0) { FileChooser fileChooser("Save as...", File::nonexistent, "*.wav", true); if (fileChooser.browseForFileToSave(true)) { File outputFile = fileChooser.getResult(); outputFile.deleteFile(); WavAudioFormat wavFormat; ScopedPointer<FileOutputStream> outputFileStream = outputFile.createOutputStream(); ScopedPointer<AudioFormatWriter> writer = wavFormat.createWriterFor(outputFileStream, 44100.0, playheadAudio.getNumChannels(), 16, StringPairArray(), 0); writer->writeFromAudioSampleBuffer(playheadAudio, 0, playheadAudio.getNumSamples()); outputFileStream.release(); } } //[/UserButtonCode_saveButton] } else if (buttonThatWasClicked == inputRemoveButton) { //[UserButtonCode_inputRemoveButton] -- add your button handler code here.. const ScopedLock fl(soundListLock); SparseSet<int> selectedRows = inputFileListComponent->getSelectedRows(); for (int i = 0; i < selectedRows.size(); ++i) { int row = selectedRows[i]; int id = inputFileListComponent->getIdForRow(row); const auto& iter = idToSound.find(id); jassert(iter != idToSound.end()); idToSound.erase(iter); } if (selectedRows.size() > 0) { inputFilesChanged(dontSendNotification); } //[/UserButtonCode_inputRemoveButton] } else if (buttonThatWasClicked == inputAddButton) { //[UserButtonCode_inputAddButton] -- add your button handler code here.. const ScopedLock fl(soundListLock); FileChooser fileChooser("Add sound...", File::nonexistent, "*.wav;*.aif;*.aiff;*.ogg", true); if (fileChooser.browseForMultipleFilesToOpen()) { Array<File> files = fileChooser.getResults(); StringArray filePaths; for (int i = 0; i < files.size(); ++i) { filePaths.add(files[i].getFullPathName()); } filesDropped(filePaths, -1, -1); } //[/UserButtonCode_inputAddButton] } //[UserbuttonClicked_Post] //[/UserbuttonClicked_Post] }