Esempio n. 1
0
void ScopeSync::addConfiguration(Rectangle<int> windowPosition)
{
    newConfigWindowPosition = windowPosition;

    FileChooser fileChooser("New Configuration File...",
                            File::nonexistent,
                            "*.configuration");
    
    File newFile;

    if (fileChooser.browseForFileToSave(true))
    {
        newFile = fileChooser.getResult();
    }
    else
    {
        return;
    }

    addConfigurationWindow = new NewConfigurationWindow
                                 (
                                 newConfigWindowPosition.getCentreX(), 
                                 newConfigWindowPosition.getCentreY(), 
                                 *this,
                                 newFile,
                                 commandManager
                                 );
    
    addConfigurationWindow->setVisible(true);
    
    if (ScopeSyncApplication::inScopeFXContext())
        addConfigurationWindow->setAlwaysOnTop(true);

    addConfigurationWindow->toFront(true);
}
Esempio n. 2
0
bool ScopeSync::saveConfigurationAs()
{
    File configurationFileDirectory = getConfigurationDirectory();
    
    FileChooser fileChooser("Save Configuration File As...",
                            configurationFileDirectory,
                            "*.configuration");
    
    if (fileChooser.browseForFileToSave(true))
    {
        String fileName = fileChooser.getResult().getFullPathName();

        if (File::isAbsolutePath(fileName))
        {
            configuration->setLastFailedFile(configuration->getFile());
            configuration->setFile(File(fileName));
            getConfigurationRoot().setProperty(Ids::ID, createAlphaNumericUID(), nullptr);
            saveConfiguration();
        }

        applyConfiguration();

        UserSettings::getInstance()->addActionListener(this);
        UserSettings::getInstance()->rebuildFileLibrary(true, false, false);

        return true;
    }
    else
        return false;
}
Esempio n. 3
0
static void field_select_file_cb(Fl_Widget *w, void *data)
{
  Fl_Input *input = (Fl_Input*)data;
  int ret = fileChooser(FILE_CHOOSER_SINGLE, "Choose", "", input->value());
  if(ret){
    input->value(fileChooserGetName(0).c_str());
    input->set_changed();
  }
}
Esempio n. 4
0
CargaDatos::CargaDatos(QWidget *parent) : QDialog(parent), ui(new Ui::CargaDatos){

    ui->setupUi(this);
    signal=new Signal();

    ui->listWidget->setViewMode(QListWidget::IconMode);
    ui->listWidget->setIconSize(QSize(96, 84));
    ui->listWidget->setMovement(QListWidget::Static);
    ui->listWidget->setMaximumWidth(128);
    ui->listWidget->setSpacing(12);
    ui->listWidget->setCurrentRow(0);
    ui->stackedPages->setCurrentIndex(0);
    connect(ui->listWidget,SIGNAL(currentRowChanged(int)),ui->stackedPages,SLOT(setCurrentIndex(int)));
    connect(ui->ButtonFileTxt,SIGNAL(clicked()),this,SLOT(fileChooser() ) );
    connect(ui->ButtonFileCsv,SIGNAL(clicked()),this,SLOT(fileChooser() ) );


}
Esempio n. 5
0
void PlayerComponent::buttonClicked (Button* buttonThatWasClicked)
{
    if (buttonThatWasClicked == browseButton)
    {
        FileChooser fileChooser(T("Select an audio file to open..."),
                                _lastWorkingDirectory,
                                _audioFormatManager.getWildcardForAllFormats(),
                                false);

        if(fileChooser.browseForFileToOpen())
        {
            File audioFile(fileChooser.getResult());
            _lastWorkingDirectory = audioFile.getParentDirectory();

            AudioFormatReader *fileReader = _audioFormatManager.createReaderFor(audioFile);

            if(fileReader)
            {
                _transportSource.stop();
                _transportSource.setSource(0);

                filenameLabel->setText(audioFile.getFileName(), false);

                delete _fileReaderSource;
                _fileReaderSource = new AudioFormatReaderSource(fileReader, true);
                _fileReaderSource->setLooping(loopButton->getToggleState());
                _transportSource.setSource(_fileReaderSource, 32768, fileReader->sampleRate);
                _transportSource.setPosition(.0f);

                _totalTime = double(fileReader->lengthInSamples) / double(fileReader->sampleRate);
                timeSlider->setRange(.0, _totalTime, 1.);
                timeSlider->setValue(.0, false, false);

                setCurrentTime();
            }
        }
    }
    else if (buttonThatWasClicked == playButton)
    {
        if(_transportSource.isPlaying())
            _transportSource.stop();
        else
            _transportSource.start();
    }
    else if (buttonThatWasClicked == stopButton)
    {
        _transportSource.stop();
        _transportSource.setPosition(0);

        setCurrentTime();
    }
    else if (buttonThatWasClicked == loopButton)
    {
        if(_fileReaderSource)
            _fileReaderSource->setLooping(loopButton->getToggleState());
    }
}
Esempio n. 6
0
// Utility method to select a map file
std::string MapFileManager::selectFile(bool open,
	const std::string& title, const std::string& type, const std::string& defaultFile)
{
	// Check, if the lastdir contains at least anything and load
	// the default map path if it's empty
	if (_lastDirs.find(type) == _lastDirs.end())
	{
		// Default to the map path, if the type is not yet associated
		_lastDirs[type] = GlobalRegistry().get(RKEY_MAP_PATH);
	}

	// Get the first extension from the list of possible patterns (e.g. *.pfb or *.map)
	FileTypePatterns patterns = GlobalFiletypes().getPatternsForType(type);

	std::string defaultExt = "";

	if (!patterns.empty())
	{
		defaultExt = "." + patterns.begin()->extension; // ".map"
	}

	// Display a file chooser dialog to get a new path
	gtkutil::FileChooser fileChooser(GlobalMainFrame().getTopLevelWindow(),
		title, open, false, type, defaultExt);

	fileChooser.setCurrentFile(defaultFile);
	fileChooser.setCurrentPath(_lastDirs[type]);

	// For prefabs, add a preview widget
	if (open && type == "prefab")
	{
		// Instantiate a new preview object
		MapFileChooserPreviewPtr preview(new MapFileChooserPreview());

		// attach the preview object
		fileChooser.attachPreview(preview);
	}

	std::string filePath = fileChooser.display();

	// If a filename was chosen, update the last path
	if (!filePath.empty())
	{
		_lastDirs[type] = filePath.substr(0, filePath.rfind("/"));
	}

	return gtkutil::IConv::localeFromUTF8(filePath);
}
Esempio n. 7
0
inline void button_clicked_entry_browse_file (GtkWidget* widget, GtkEntry* entry)
{
	std::string filename = gtk_entry_get_text(entry);

	gtkutil::FileChooser fileChooser(gtk_widget_get_toplevel(widget), _("Choose File"), true, false);
	if (!filename.empty()) {
		fileChooser.setCurrentPath(os::stripFilename(filename));
		fileChooser.setCurrentFile(filename);
	}

	std::string file = fileChooser.display();

	if (GTK_IS_WINDOW(gtk_widget_get_toplevel(widget))) {
		gtk_window_present(GTK_WINDOW(gtk_widget_get_toplevel(widget)));
	}

	if (!file.empty()) {
		gtk_entry_set_text(entry, file.c_str());
	}
}
void LufsPluginEditor::exportToText( bool useCommasForDigitSeparation )
{
    LufsAudioProcessor* processor = getProcessor();

    const int updateSize = processor->m_lufsProcessor.getValidSize();

    const juce::String saveDirString( "saveDirectory" );
    const juce::String saveDir = getProcessor()->m_settings.getUserSettings()->getValue( saveDirString );

    juce::File directory;
    if ( saveDir.length() )
        directory = juce::File( directory );
    if ( !directory.exists() )
        directory = juce::File::getSpecialLocation( juce::File::userHomeDirectory );

    juce::FileChooser fileChooser( "Select text output file", directory, "*.txt" );
    if ( fileChooser.browseForFileToSave( true ) )
    {
        juce::File file( fileChooser.getResult() );
        if ( ! file.deleteFile() )
        {
            juce::AlertWindow::showMessageBox( juce::AlertWindow::NoIcon, "Unable to delete existing file, not saving.", "" );
            return;
        }

        // save chosen directory
        getProcessor()->m_settings.getUserSettings()->getValue( saveDirString, file.getParentDirectory().getFullPathName() );

        juce::FileOutputStream outputStream( file );

        juce::String text = "Time\tMomentary\tShort Term\tIntegrated\n";

        for ( int tens = 0; tens < updateSize ; tens += 10 )
        {
            // add time 
            const int seconds = tens / 10;
            const int hours = seconds / 3600;
            const int minutes = ( seconds - hours * 60 ) / 60;
            int shownSeconds = seconds - hours * 3600 - minutes * 60;
            juce::String line( hours );
            line << ":";
            if ( minutes < 10 )
                line << "0";
            line << minutes;
            line << ":";
            if ( shownSeconds < 10 )
                line << "0";
            line << shownSeconds;
            line << "\t";

            // add momentary
            line << juce::String( processor->m_lufsProcessor.getMomentaryVolumeArray()[ tens ], 1 );
            line << "\t";

            // add short term
            line << juce::String( processor->m_lufsProcessor.getShortTermVolumeArray()[ tens ], 1 );
            line << "\t";

            // add integrated
            line << juce::String( processor->m_lufsProcessor.getIntegratedVolumeArray()[ tens ], 1 );
            line << "\n";

            if ( useCommasForDigitSeparation )
                line = line.replaceCharacter( '.', ',' );

            text << line;
        }

        outputStream.writeText( text, false, false );
    }
}
Esempio n. 9
0
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]
}
Esempio n. 10
0
//----------------------------------------------------------------------
const FString FFileDialog::fileSaveChooser ( FWidget* parent
                                           , const FString& dirname
                                           , const FString& filter )
{
  return fileChooser (parent, dirname, filter, FFileDialog::Save);
}