Exemple #1
0
PyObject* getTrackEffects(PyObject*, PyObject* args)
{
	const char* trackname;
	if (!PyArg_ParseTuple(args, "s", &trackname))
	{
		return NULL;
	}

	Track* t = song->findTrack(QString(trackname));
	if (t == NULL)
		return NULL;

	if (t->type() != Track::WAVE)
		return NULL;

	AudioTrack* track = (AudioTrack*) t;
	PyObject* pyfxnames = Py_BuildValue("[]");
	const Pipeline* pipeline = track->efxPipe();
	if(pipeline)
	{
		int pdepth = pipeline->size();
		for (int i = 0; i < pdepth; i++)
		{
			QString name = pipeline->name(i);
			printf("fx %d name: %s\n", i, name.toLatin1());
			PyObject* pyname = Py_BuildValue("s", name.toLatin1());
			PyList_Append(pyfxnames, pyname);
			Py_DECREF(pyname);
		}
	}

	return pyfxnames;
}
Exemple #2
0
bool Song::event(QEvent* _e)
{
	if (_e->type() != QEvent::User)
		return false; //ignore all events except user events, which are events from Python bridge subsystem

	QPybridgeEvent* e = (QPybridgeEvent*) _e;
	switch (e->getType())
	{
		case QPybridgeEvent::SONG_UPDATE:
			this->update(e->getP1());
			break;
		case QPybridgeEvent::SONGLEN_CHANGE:
			this->setLen(e->getP1());
			break;
		case QPybridgeEvent::SONG_POSCHANGE:
			this->setPos(e->getP1(), e->getP2());
			break;
		case QPybridgeEvent::SONG_SETPLAY:
			this->setPlay(true);
			break;
		case QPybridgeEvent::SONG_SETSTOP:
			this->setStop(true);
			break;
		case QPybridgeEvent::SONG_REWIND:
			this->rewindStart();
			break;
		case QPybridgeEvent::SONG_SETMUTE:
		{
			Track* track = this->findTrack(e->getS1());
			if (track == NULL)
				return false;

			bool muted = e->getP1() == 1;
			track->setMute(muted);
			this->update(SC_MUTE | SC_TRACK_MODIFIED);
			break;
		}
		case QPybridgeEvent::SONG_SETCTRL:
		{
			Track* t = this->findTrack(e->getS1());
			if (t == NULL)
				return false;

			if (t->isMidiTrack() == false)
				return false;

			MidiTrack* track = (MidiTrack*) t;
			int chan = track->outChannel();

			int num = e->getP1();
			int val = e->getP2();
			int tick = song->cpos();
			MidiPlayEvent ev(tick, track->outPort(), chan, ME_CONTROLLER, num, val, t);
			audio->msgPlayMidiEvent(&ev);
			song->update(SC_MIDI_CONTROLLER);
			break;
		}
		case QPybridgeEvent::SONG_SETAUDIOVOL:
		{
			Track* t = this->findTrack(e->getS1());
			if (t == NULL)
				return false;

			if (t->type() == Track::DRUM || t->type() == Track::MIDI)
				return false;

			AudioTrack* track = (AudioTrack*) t;
			track->setVolume(e->getD1());
			break;
		}
		case QPybridgeEvent::SONG_IMPORT_PART:
		{
			Track* track = this->findTrack(e->getS1());
			QString filename = e->getS2();
			unsigned int tick = e->getP1();
			if (track == NULL)
				return false;

			oom->importPartToTrack(filename, tick, track);
			break;
		}
		case QPybridgeEvent::SONG_TOGGLE_EFFECT:
		{
			Track* t = this->findTrack(e->getS1());
			if (t == NULL)
				return false;

			if (t->type() != Track::WAVE)
				return false;

			int fxid = e->getP1();


			int onoff = (e->getP2() == 1);

			AudioTrack* track = (AudioTrack*) t;
			Pipeline* pipeline = track->efxPipe();
			const Pipeline* pipeline = track->efxPipe();
			if(pipeline)
			{
				int pdepth = pipeline->size();
				if (fxid > pdepth)
					return false;
				pipeline->setOn(fxid, onoff);
			}
			break;
		}
		case QPybridgeEvent::SONG_ADD_TRACK:
			song->addTrack(e->getP1());
			song->updateTrackViews();
			break;
		case QPybridgeEvent::SONG_CHANGE_TRACKNAME:
		{
			Track* t = this->findTrack(e->getS1());
			if (t == NULL)
				return false;
			t->setName(e->getS2());
			break;
		}
		case QPybridgeEvent::SONG_DELETE_TRACK:
		{
			Track* t = this->findTrack(e->getS1());
			if (t == NULL)
				return false;

			audio->msgRemoveTrack(t);
			break;
		}
		default:
			printf("Unknown pythonthread event received: %d\n", e->getType());
			break;
	}


	return true;
}