Ejemplo n.º 1
0
void QOpenSLESAudioOutput::start(QIODevice *device)
{
    Q_ASSERT(device);
    if (!preparePlayer())
        return;

    m_pullMode = true;
    m_audioSource = device;
    setState(QAudio::ActiveState);
    setError(QAudio::NoError);

    // Attempt to fill buffers first.
    for (int i = 0; i != BUFFER_COUNT; ++i) {
        const int index = i * m_bufferSize;
        const qint64 readSize = m_audioSource->read(m_buffers + index, m_bufferSize);
        if (readSize && SL_RESULT_SUCCESS != (*m_bufferQueueItf)->Enqueue(m_bufferQueueItf,
                                                                          m_buffers + index,
                                                                          readSize)) {
            setError(QAudio::FatalError);
            destroyPlayer();
            return;
        }
        m_processedBytes += readSize;
    }

    // Change the state to playing.
    // We need to do this after filling the buffers or processedBytes might get corrupted.
    startPlayer();
}
Ejemplo n.º 2
0
void JVlibForm::on_System_PauseMidi_button_toggled(bool checked)
{
  unsigned int current_tick;
  if (checked) {
      stopPlayer();
      if (seqTimer->isActive()) {
            disconnect(JVlibForm::seqTimer, SIGNAL(timeout()), this, SLOT(tickDisplay()));
            seqTimer->stop();
      }
        snd_seq_get_queue_status(seq, queue, status);
	current_tick = snd_seq_queue_status_get_tick_time(status);
        snd_seq_stop_queue(seq,queue,NULL);
        snd_seq_drain_output(seq);
	stop_sound();
	disconnect_port();
        System_PauseMidi_button->setText("Resume");
  }
  else {
	connect_port();
        snd_seq_continue_queue(seq, queue, NULL);
        snd_seq_drain_output(seq);
        snd_seq_get_queue_status(seq, queue, status);
	current_tick = snd_seq_queue_status_get_tick_time(status);
        System_PauseMidi_button->setText("Pause");
        connect(JVlibForm::seqTimer, SIGNAL(timeout()), this, SLOT(tickDisplay()));
	startPlayer(current_tick);
        seqTimer->start(100);
  }
}   // end on_System_PauseMidi_button_toggled
Ejemplo n.º 3
0
int DM_Music_PlayFile(const char *filename, int looped)
{
    if(!filename) return false;

    if(!fluid_is_midifile(filename))
    {
        // It doesn't look like MIDI.
        App_Log(DE2_LOG_VERBOSE, "[FluidSynth] Cannot play \"%s\": not a MIDI file", filename);
        return false;
    }

    if(sfontId < 0)
    {
        App_Log(DE2_LOG_VERBOSE, "[FluidSynth] Cannot play \"%s\" without an SF2 soundfont", filename);
        return false;
    }

    // If we are playing something, make sure it's stopped.
    stopPlayer();

    DENG_ASSERT(fsPlayer == NULL);

    // Create a new player.
    fsPlayer = new_fluid_player(DMFluid_Synth());
    fluid_player_add(fsPlayer, filename);
    fluid_player_set_loop(fsPlayer, looped? -1 /*infinite times*/ : 1);
    fluid_player_play(fsPlayer);

    startPlayer();

    DSFLUIDSYNTH_TRACE("PlayFile: playing '" << filename << "' using player "
                       << fsPlayer << " looped:" << looped << " sfont:" << sfontId);
    return true;
}
Ejemplo n.º 4
0
int main (int argc, char **argv)
{
	srand(time(0));

	MAP map;
	setDefaults(&map);

	PLAYER hero;
	startPlayer(&hero);

	getargs(&map, &hero, argc, argv);

	startMap(&map);
	hero.face = map.elements.hero.face;
	hero.pos = putElement(&map, hero.face);

	GHOSTS ghosts;
	ghosts.face = GHOST;
	ghosts.count = 0;

	startGhosts(&map, &ghosts);

	fflush(stdout);
	initscr();
	nodelay(stdscr, TRUE);
	noecho();
	keypad(stdscr, TRUE);

	if (map.props.hascolor)
		startColors();

	struct timespec tim, tim2;
	tim.tv_sec = 0;
	tim.tv_nsec = map.props.speed;

	do {
		nanosleep(&tim, &tim2);
		getCommand(&hero);
		walk(&map, &hero, &ghosts);
		showMap(&map, &hero, &ghosts);
		repopMap(&map);
		upGhosts(&map, &ghosts);
		walkGhosts(&map, &ghosts);

	} while (!isDead(&hero));

	if (!noRecords)
		writeRecords(&hero, &ghosts);
	finalize(&map, &ghosts);
	finalText(&map, &hero, &ghosts);

	exit(0);

}
void AudioPlayerControlRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
{
    Q_UNUSED(context)
    QDBusInterface tracklist(QString::fromLatin1( "org.mpris.%1").arg(m_player),
                             QLatin1String( "/TrackList" ), QLatin1String( "org.freedesktop.MediaPlayer" ));

    QVariantList data = match.data().value<QVariantList>();

    /* Only Amarok part*/
    QString url = data[2].toString();
    int pos = posInPlaylist(url);
    kDebug() << "pos" << pos;
    QAction *a = match.selectedAction();
    if (data[3].toString().compare(NONE)) {
        if (!a)
        {
            a = action(data[3].toString());
        }
        if (a == action(QUEUE)) {
            KUrl::List list;
            list << KUrl(url);
            KRun::run(QLatin1String( "amarok --queue %u" ), list, 0);
        } else if (a == action(APPEND)) {
            if (!(pos > -1)) {
                tracklist.call(QDBus::NoBlock, QLatin1String( "AddTrack" ), url , false);
            }
        } else {
            //Action play was selected
            if (pos > -1) {
                tracklist.call(QDBus::NoBlock, QLatin1String( "PlayTrack" ), pos);
            } else {
                tracklist.call(QDBus::NoBlock, QLatin1String( "AddTrack" ), url, true);
            }
        }
    }/* Only Amarok part over */ else {
        if ((data[4].toString().compare(QLatin1String( "start" )) == 0)) {
            //The players's interface isn't available but it should be started
            if (!startPlayer()) {
                return;
            }
        }

        QDBusMessage msg = QDBusMessage::createMethodCall(QString::fromLatin1( "org.mpris.%1").arg(m_player),data[0].toString(),
                           data[1].toString(), data[2].toString());
        kDebug() << msg;
        QVariantList args;
        for (int i = 5;data.length() > i;++i) {
            args << data[i];
        }
        msg.setArguments(args);
        QDBusConnection::sessionBus().call(msg, QDBus::NoBlock);
    }
}
Ejemplo n.º 6
0
void Phone::receivedCall(int callId)
{
	try
	{
		call_number++;
		startPlayer();
		timer->start(TICKTIME, false);
		emit receivedCallSignal(callId);
	}
	catch (Error e)
	{
		emit abortSignal(e.getText());
	}
}
Ejemplo n.º 7
0
QIODevice *QOpenSLESAudioOutput::start()
{
    if (!preparePlayer())
        return Q_NULLPTR;

    m_pullMode = false;
    m_audioSource = new SLIODevicePrivate(this);
    m_audioSource->open(QIODevice::WriteOnly | QIODevice::Unbuffered);

    // Change the state to playing
    startPlayer();

    setState(QAudio::IdleState);
    return m_audioSource;
}
Ejemplo n.º 8
0
void Phone::disablePlayer(bool on)
{
	if (on)
	{
		stopPlayer();
		play_status = PLAYER_STATUS_MUTE;
	}
	else
	{
		play_status = PLAYER_STATUS_STOP;
		if (call_number > 0)
		{
			startPlayer();
		}
	}
}
Ejemplo n.º 9
0
void JVlibForm::on_System_PlayMidi_button_toggled(bool checked) {
    if (checked) {
	seqTimer = new QTimer(this);
        System_PauseMidi_button->setEnabled(true);
        System_OpenMidi_button->setEnabled(false);
        System_PlayMidi_button->setText("Stop");
	System_MIDI_progressBar->setEnabled(true);
        connect_port();
        // queue won't actually start until it is drained
        int err = snd_seq_start_queue(seq, queue, NULL);
        check_snd("start queue", err);
	System_PlayMidi_status->on();
        connect(JVlibForm::seqTimer, SIGNAL(timeout()), this, SLOT(tickDisplay()));
        seqTimer->start(100);
	startPlayer(0);
    }
    else {
        if (seqTimer->isActive()) {
            disconnect(JVlibForm::seqTimer, SIGNAL(timeout()), this, SLOT(tickDisplay()));
            seqTimer->stop();
	    delete seqTimer;
        }
        snd_seq_stop_queue(seq,queue,NULL);
        snd_seq_drain_output(seq);
	stopPlayer();
	stop_sound();
        disconnect_port();
	System_PlayMidi_status->off();
	System_MIDI_progressBar->blockSignals(true);
        System_MIDI_progressBar->setValue(0);
	System_MIDI_progressBar->blockSignals(false);
        MIDI_time_display->setText("00:00");
        if (System_PauseMidi_button->isChecked()) {
            System_PauseMidi_button->blockSignals(true);
            System_PauseMidi_button->setChecked(false);
            System_PauseMidi_button->blockSignals(false);
            System_PauseMidi_button->setText("Pause");
        }
        System_PauseMidi_button->setEnabled(false);
        System_PlayMidi_button->setText("Play");
        System_OpenMidi_button->setEnabled(true);
	System_MIDI_Transpose->setEnabled(true);
	System_MIDI_progressBar->setEnabled(false);
	event_num=0;
    }
}   // end on_System_PlayMidi_button_toggled
Ejemplo n.º 10
0
void onEvent(EventCode ec) {
    switch (ec) {
    case EV_STOP:
        if (playflag == true || pauseflag == true)
            stopPlayer();
        break;

    case EV_PLAY_PAUSE:
        if (playflag == true) pausePlayer();
        else if (pauseflag == true) resumePlayer();
        else startPlayer();
        break;

    default:
        break;
    }
}
Ejemplo n.º 11
0
void Phone::call(int callId, QString host, int port, int prot)
{
	if (calls[callId])
	{
		try
		{
			calls[callId]->call(host, port, prot);
			startPlayer();
			startRecorder();
			timer->start(TICKTIME, false);
			call_number++;
		}
		catch (Error e)
		{
			abortCall(callId);
			e.setCallId(callId);
			throw e;
		}
	}
	else throw Error("invalid call ID");
}
Ejemplo n.º 12
0
//--------------------------------------------------------------- ACTIONS
void CloudsRGBDVideoPlayer::update(ofEventArgs& args){
	
	if(!playingVO){
		currentPlayer->update();
	}
	
	if(bLoadResult && clipPrerolled && !nextClipIsVO){
		nextPlayer->update();
	}

	if(bPlayWhenReady && bLoadResult){
		cout << "*** STARTING PLAYER FROM UPDATE" << endl;
		startPlayer();
		bPlayWhenReady = false;
	}

    float audioVolume =  maxVolume * currentClipVolumeAdjustment;

	if(playingVO){
		currentVoiceoverPlayer->setVolume(audioVolume);
	}
	else{
		float position = getPlayer().getPosition()*getPlayer().getDuration();
		float duration = getPlayer().getDuration();
//		float handleLength = 1.1;
		
		//sometimes NAN comes back from position.
		if(position != position){
			return;
		}
        
		//cout << "position is " << position << " " << duration << " duration " << endl;
		
		fadeInValue = MIN(position, 1.0);
		fadeOutValue = ofMap(position, duration - 1.0, duration, 1.0, 0.0, true);
        
		//remap to make it tigheter
        fadeInValue  = powf(ofMap(fadeInValue,  .5, 1.0, 0.0, 1.0, true), 2.0);
        fadeOutValue = powf(ofMap(fadeOutValue, .5, 1.0, 0.0, 1.0, true), 2.0);
		
		float fadeInStartTime = 1.0;
		float fadeInEndTime = 1.4;
		float fadeOutStartTime = duration - 1.3 ;
		float fadeOutEndTime = duration - 1.0;
		if(position < 1.0){
			audioVolume = ofMap(position, fadeInStartTime, fadeInEndTime, 0., maxVolume, true);
		}
		else if(position > fadeOutStartTime){
			audioVolume = ofMap(position, fadeOutStartTime, fadeOutEndTime, maxVolume, 0.0, true);
		}
		
		getPlayer().setVolume(audioVolume);

		if(forceStop && position > duration - .04){
			getPlayer().stop();
		}
        
        /* Subtitles */
        if (currentClipHasSubtitles) {
#ifdef SHOW_SUBTITLES
			currentSubtitles.setTimeInSeconds(getPlayer().getPosition()*getPlayer().getDuration());
#endif
        }
	}
}
Ejemplo n.º 13
0
void CloudsRGBDVideoPlayer::swapAndPlay(){
	
	cout << "*** SWAPPING CLIP" << endl;

	if(!nextClipIsVO){
		
		ofxXmlSettings XML;
		if ( !XML.loadFile(nextCalibrationXML) ){
			ofLogError("CloudsRGBDVideoPlayer::setup") << "XML Path " << nextCalibrationXML << " failed to load";
			return;
		}
		
		colorPrincipalPoint.x = XML.getValue("colorIntrinsics:ppx", 971.743835449);
		colorPrincipalPoint.y = XML.getValue("colorIntrinsics:ppy", 546.945983887);
		colorFOV.x = XML.getValue("colorIntrinsics:fovx", 923.500793457);
		colorFOV.y = XML.getValue("colorIntrinsics:fovy", 921.060791016);
		colorRect.x = 0.0f;
		colorRect.y = 0.0f;
		colorRect.width = XML.getValue("colorIntrinsics:width", 1920.000000000);
		colorRect.height = XML.getValue("colorIntrinsics:height", 1080.000000000);
		
		float depthToRGBRotation[9];
		float depthToRGBTranslation[3];
		for (int i = 0; i < 9; i++) {
			depthToRGBRotation[i] = XML.getValue("extrinsics:rotation:r"+ofToString(i), 1.0f);
		}
		
		for (int i = 0; i < 3; i++) {
			depthToRGBTranslation[i] = XML.getValue("extrinsics:translation:t"+ofToString(i), 1.0f);
		}
		
		for (int i = 0; i < 3; i++) {
			distortionK[i] = XML.getValue("colorIntrinsics:dK:k"+ofToString(i), 1.0f);
		}
		
		for (int i = 0; i < 2; i++) {
			distortionP[i] = XML.getValue("colorIntrinsics:dP:p"+ofToString(i), 1.0f);
		}
		
		headPosition = ofVec3f(-XML.getValue("face:x", 0.0),
							   -XML.getValue("face:y", 0.0),
							    XML.getValue("face:z", 0.0));
		
		//cout << "head position " << headPosition << endl;
		
		float mat4x4[16] = {
			depthToRGBRotation[0],depthToRGBRotation[1],depthToRGBRotation[2],0,
			depthToRGBRotation[3],depthToRGBRotation[4],depthToRGBRotation[5],0,
			depthToRGBRotation[6],depthToRGBRotation[7],depthToRGBRotation[8],0,
			depthToRGBTranslation[0],depthToRGBTranslation[1],depthToRGBTranslation[2],1
		};
		
		extrinsics = ofMatrix4x4(mat4x4);
		
		//	cout << "extrinsic matrix: " << endl << extrinsics << endl;
		
		//adjustment
		adjustTranslate.x = XML.getValue("adjustment:translate:x", 0.0);
		adjustTranslate.y = XML.getValue("adjustment:translate:y", 0.0);
		adjustTranslate.z = XML.getValue("adjustment:translate:z", 0.0);
		
		adjustRotate.x = XML.getValue("adjustment:rotate:x", 0.0);
		adjustRotate.y = XML.getValue("adjustment:rotate:y", 0.0);
		adjustRotate.z = XML.getValue("adjustment:rotate:z", 0.0);
		
		adjustScale.x = XML.getValue("adjustment:scale:x", 1.0);
		adjustScale.y = XML.getValue("adjustment:scale:y", 1.0);
		
		depthPrincipalPoint.x = XML.getValue("depthIntrinsics:ppx", 320.0);
		depthPrincipalPoint.y = XML.getValue("depthIntrinsics:ppy", 240.0);
		depthFOV.x = XML.getValue("depthIntrinsics:fovx", 570.34);
		depthFOV.y = XML.getValue("depthIntrinsics:fovy", 570.34);
		
		depthRect.x = 0.0;      //  TODO: do this automatically
		depthRect.y = 720.0;    //
		depthRect.width = XML.getValue("depthIntrinsics:width", 640.0);
		depthRect.height = XML.getValue("depthIntrinsics:height", 480.0);
		
		normalRect.x = 640.0;       //  TODO: do this automatically
		normalRect.y = 720.0;       //
		normalRect.width = 640.0;
		normalRect.height = 480.0;
		
		nearClip = minDepth = XML.getValue("adjustment:depth:min", 1.0f);
		farClip = maxDepth = XML.getValue("adjustment:depth:max", 6000.0f);
		
		////////-----NO LONGER USED
		//this describes the face features: eyes, mouth, and skin
		faceFeatureRect = ofRectangle(depthRect.x, depthRect.getMaxY(), 640, 360);
		//this describes the change each frame
		deltaChangeRect = ofRectangle(normalRect.x, normalRect.getMaxY(), 640, 360);
		////////////
		
		hasSkinSettings = XML.tagExists("skin");
		skinSampleColor.r = XML.getValue("skin:targetR", 0.);
		skinSampleColor.g = XML.getValue("skin:targetG", 0.);
		skinSampleColor.b = XML.getValue("skin:targetB", 0.);
		skinWeights.x = XML.getValue("skin:hueWeight", 0.);
		skinWeights.y = XML.getValue("skin:satWeight", 0.);
		skinWeights.z = XML.getValue("skin:brightWeight", 0.);
		skinThreshold.min = XML.getValue("skin:lowerThreshold", .0);
		skinThreshold.max = XML.getValue("skin:upperThreshold", 1.0);
		
//		cout << "HAS SKIN? " << hasSkinSettings << endl;

		//	float colorWidth  = getPlayer().getWidth();
		//	float colorHeight = getPlayer().getHeight();
		float colorWidth  = 1280;
		float colorHeight = 1560;
		colorScale.x = colorWidth / colorRect.width;
		colorScale.y = float(colorHeight - (depthRect.height + faceFeatureRect.height) ) / float(colorRect.height);
		useFaces = true;
	}

	if(clipPrerolled){
		if(bLoadResult){
			cout << "*** STARTING PLAYER FROM SWAP" << endl;
			startPlayer();
		}
		else{
			bPlayWhenReady = true;
		}
	}
}
Ejemplo n.º 14
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
	ui.setupUi(this);

	QSettings settings;

	libraryWidget_ = new LibraryWidget;
	setCentralWidget(libraryWidget_);

	{
		outputDock_ = new QDockWidget(tr("Output"), this);
		outputDock_->setObjectName("output");
		outputWidget_ = new QTextEditEx(outputDock_);
		connect(outputWidget_, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(outputMouseDoubleClick(QMouseEvent*)));
		outputWidget_->setReadOnly(true);
		outputDock_->setWidget(outputWidget_);
		addDockWidget(Qt::BottomDockWidgetArea, outputDock_);
	}

	ui.actionStart_Player->setIcon(IconLibrary::instance().icon("gamepad"));
	connect(ui.actionStart_Player, SIGNAL(triggered()), this, SLOT(startPlayer()));

	ui.actionStart->setIcon(IconLibrary::instance().icon("start"));
	ui.actionStart->setEnabled(false);
	connect(ui.actionStart, SIGNAL(triggered()), this, SLOT(start()));

	ui.actionStop->setIcon(IconLibrary::instance().icon("stop"));
	ui.actionStop->setEnabled(false);
	connect(ui.actionStop, SIGNAL(triggered()), this, SLOT(stop()));

	connect(ui.actionNew_Project, SIGNAL(triggered()), this, SLOT(newProject()));
	connect(ui.actionClose_Project, SIGNAL(triggered()), this, SLOT(closeProject()));
	connect(ui.actionSave_Project, SIGNAL(triggered()), this, SLOT(saveProject()));
	connect(ui.actionOpen_Project, SIGNAL(triggered()), this, SLOT(openProject()));
	connect(ui.actionExport_Project, SIGNAL(triggered()), this, SLOT(exportProject()));

	connect(ui.actionProject1, SIGNAL(triggered()), this, SLOT(openRecentProject()));
	connect(ui.actionProject2, SIGNAL(triggered()), this, SLOT(openRecentProject()));
	connect(ui.actionProject3, SIGNAL(triggered()), this, SLOT(openRecentProject()));
	connect(ui.actionProject4, SIGNAL(triggered()), this, SLOT(openRecentProject()));
	connect(ui.actionProject5, SIGNAL(triggered()), this, SLOT(openRecentProject()));

	connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close()));

	connect(ui.actionPlayer_Settings, SIGNAL(triggered()), this, SLOT(playerSettings()));

	connect(ui.actionFile_Associations, SIGNAL(triggered()), this, SLOT(fileAssociations()));

	connect(libraryWidget_, SIGNAL(openRequest(const QString&, const QString&)), this, SLOT(onOpenRequest(const QString&, const QString&)));


	QString playerip = settings.value("player ip", QString("127.0.0.1")).toString();

	client_ = new GiderosNetworkClient(playerip, 15000);

	connect(client_, SIGNAL(connected()), this, SLOT(connected()));
	connect(client_, SIGNAL(disconnected()), this, SLOT(disconnected()));
	connect(client_, SIGNAL(dataReceived(const QByteArray&)), this, SLOT(dataReceived(const QByteArray&)));
	connect(client_, SIGNAL(ackReceived(unsigned int)), this, SLOT(ackReceived(unsigned int)));

	updateUI();

	setWindowTitle(tr("Gideros"));

	updateRecentProjectActions();

	QTimer* timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), this, SLOT(onTimer()));
	timer->start(1);

	isTransferring_ = false;

	QList<QVariant> v = settings.value("fileAssociations", QList<QVariant>()).toList();
	for (int i = 0; i < v.size(); ++i)
		fileAssociations_.push_back(v[i].toStringList());

	localServer_.listen("GiderosProjectManager");
	connect(&localServer_, SIGNAL(newConnection()), this, SLOT(onLocalServerNewConnection()));

	restoreGeometry(settings.value("geometry").toByteArray());
	restoreState(settings.value("windowState").toByteArray());
}