Exemple #1
0
static void getConfigSetting(const PluginSettings &plugin, QVariantMap &setting, const QString &group = QString()) {
    QString key = setting.value("key").toString();

    if (key.isEmpty()) {
        return;
    }
    
    if (!group.isEmpty()) {
        key.prepend("/");
        key.prepend(group);
    }

    const QString type = setting.value("type").toString();

    if (type == "group") {
        QVariantList settings = setting.value("settings").toList();
        
        for (int i = 0; i < settings.size(); i++) {
            QVariantMap map = settings.at(i).toMap();
            getConfigSetting(plugin, map, key);
            settings[i] = map;
        }

        setting["settings"] = settings;
    }
    else {
        setting["value"] = plugin.value(key, setting.value("value"));
    }
}     
Exemple #2
0
int ALSAMidiDriver::open() {
	std::string arg;
	unsigned int caps;

	if (isOpen)
		return -1;

	arg = getConfigSetting("alsa_port", ALSA_PORT);

	if (parse_addr(arg, &seq_client, &seq_port) < 0) {
		perr << "ALSAMidiDriver: Invalid port: " << arg << std::endl;
		return -1;
	}
	
	if (my_snd_seq_open(&seq_handle)) {
		perr << "ALSAMidiDriver: Can't open sequencer" << std::endl;
		return -1;
	}

	isOpen = true;
	
	my_client = snd_seq_client_id(seq_handle);
	snd_seq_set_client_name(seq_handle, "PENTAGRAM");
	snd_seq_set_client_group(seq_handle, "input");
	
	caps = SND_SEQ_PORT_CAP_READ;
	if (seq_client == SND_SEQ_ADDRESS_SUBSCRIBERS)
		caps = ~SND_SEQ_PORT_CAP_SUBS_READ;
	my_port =
		snd_seq_create_simple_port(seq_handle, "PENTAGRAM", caps,
								   SND_SEQ_PORT_TYPE_MIDI_GENERIC | SND_SEQ_PORT_TYPE_APPLICATION);
	if (my_port < 0) {
		snd_seq_close(seq_handle);
		isOpen = false;
		perr << "ALSAMidiDriver: Can't create port" << std::endl;
		return -1;
	}

	if (seq_client != SND_SEQ_ADDRESS_SUBSCRIBERS) {
		/* subscribe to MIDI port */
		if (snd_seq_connect_to(seq_handle, my_port, seq_client, seq_port) < 0) {
			snd_seq_close(seq_handle);
			isOpen = false;
			perr << "ALSAMidiDriver: "
				 << "Can't subscribe to MIDI port (" << seq_client
				 << ":" << seq_port << ")" << std::endl;
			return -1;
		}
	}

	pout << "ALSA client initialised [" << seq_client << ":"
		 << seq_port << "]" << std::endl;

	return 0;
}
Exemple #3
0
static QVariantList getConfigSettings(const ServicePluginConfig *config) {
    QVariantList settings = config->settings();

    if (settings.isEmpty()) {
        return settings;
    }

    PluginSettings plugin(config->id());

    for (int i = 0; i < settings.size(); i++) {
        QVariantMap setting = settings.at(i).toMap();
        getConfigSetting(plugin, setting);
        settings[i] = setting;
    }

    return settings;
}
int FluidSynthMidiDriver::open() {

	if (!stereo) {
		perr << "FluidSynth only works with Stereo output" << std::endl;
		return -1;
	}

	std::string soundfont = getConfigSetting("soundfont", "");

	if (soundfont == "") {
		perr << "FluidSynth requires a 'soundfont' setting" << std::endl;
		return -2;
	}

	_settings = new_fluid_settings();

	// The default gain setting is ridiculously low, but we can't set it
	// too high either or sound will be clipped. This may need tuning...

	setNum("synth.gain", 2.1);
	setNum("synth.sample-rate", sample_rate);

	_synth = new_fluid_synth(_settings);

	// In theory, this ought to reduce CPU load... but it doesn't make any
	// noticeable difference for me, so disable it for now.

	// fluid_synth_set_interp_method(_synth, -1, FLUID_INTERP_LINEAR);
	// fluid_synth_set_reverb_on(_synth, 0);
	// fluid_synth_set_chorus_on(_synth, 0);

	_soundFont = fluid_synth_sfload(_synth, soundfont.c_str(), 1);
	if (_soundFont == -1) {
		perr << "Failed loading custom sound font '" << soundfont << "'" << std::endl;
		return -3;
	}

	return 0;
}
Exemple #5
0
void
ASSOscClient::onUpdateSettings(dom::NodePtr theSettings) {
    AC_INFO << "Reconfiguring osc sender";

    ASSDriver::onUpdateSettings(theSettings);

    dom::NodePtr mySettings = getASSSettings(theSettings);

    int mySourcePort = 0;
    getConfigSetting(mySettings, "OscSourcePort", mySourcePort, 3333);

    _myReceivers.clear();

    dom::NodePtr myReceiversNode = mySettings->childNode("OscReceivers");
    if (myReceiversNode) {
    	unsigned myNumReceivers = myReceiversNode->childNodesLength("OscReceiver");
        for (unsigned i = 0; i < myNumReceivers; i++) {
            dom::NodePtr myReceiverNode = myReceiversNode->childNode("OscReceiver", i);

            std::string myHost = myReceiverNode->getAttributeString("host");
            asl::Unsigned16 myPort = myReceiverNode->getAttributeValue<asl::Unsigned16>("port");

            AC_INFO << "Sending from port " << mySourcePort << " to " << myHost << ":" << myPort;

            ASSOscReceiverPtr myReceiver(new ASSOscReceiver(myHost, mySourcePort, myPort));

            if (myReceiverNode->getAttribute("region")) {
                asl::Box2f myRegion = myReceiverNode->getAttributeValue<asl::Box2f>("region");

                myReceiver->restrictToRegion(myRegion);
            }

            _myReceivers.push_back(myReceiver);
        }
    }
}
Exemple #6
0
int FluidSynthMidiDriver::open() {

	if (!stereo) {
		perr << "FluidSynth only works with Stereo output" << std::endl;
		return -1;
	}

	std::string sfsetting = "fluidsynth_soundfont";
	std::vector<std::string> soundfonts;
	std::string soundfont;
	for (size_t i = 0; i < 10; i++) {
		std::string settingkey = sfsetting + static_cast<char>(i + '0');
		soundfont = getConfigSetting(settingkey, "");
		if (!soundfont.empty())
			soundfonts.push_back(soundfont);
	}
	soundfont = getConfigSetting(sfsetting, "");
	if (!soundfont.empty())
		soundfonts.push_back(soundfont);

	if (soundfonts.empty()) {
		perr << "FluidSynth requires a 'fluidsynth_soundfont' setting" << std::endl;
		return -2;
	}

	_settings = new_fluid_settings();

	// The default gain setting is ridiculously low, but we can't set it
	// too high either or sound will be clipped. This may need tuning...

	setNum("synth.gain", 2.1);
	setNum("synth.sample-rate", sample_rate);

	_synth = new_fluid_synth(_settings);

	// In theory, this ought to reduce CPU load... but it doesn't make any
	// noticeable difference for me, so disable it for now.

	// fluid_synth_set_interp_method(_synth, -1, FLUID_INTERP_LINEAR);
	// fluid_synth_set_reverb_on(_synth, 0);
	// fluid_synth_set_chorus_on(_synth, 0);

	int numloaded = 0;
	for (std::vector<std::string>::const_iterator it = soundfonts.begin();
	     it != soundfonts.end(); ++it)
	{
		int soundFont = fluid_synth_sfload(_synth, it->c_str(), 1);
		if (soundFont == -1) {
			perr << "Failed loading custom sound font '" << *it << "'" << std::endl;
		} else {
			perr << "Loaded custom sound font '" << *it << "'" << std::endl;
			_soundFont.push(soundFont);
			numloaded++;
		}
		
	}
	if (numloaded == 0) {
		perr << "Failed to load any custom sound fonts; giving up." << std::endl;
		return -3;
	}

	return 0;
}