예제 #1
0
void ALSADrv_MIDI_SetTempo(int tempo, int division)
{
    double tps;
    snd_seq_queue_tempo_t * t;
    int result;

    if (queueRunning) {
        snd_seq_stop_queue(seq, seq_queue, NULL);
        while ((result = snd_seq_drain_output(seq)) > 0) ;
        if (result < 0) {
            fprintf(stderr, "ALSA could not drain output: err %d\n", result);
        }
    }

    snd_seq_queue_tempo_alloca(&t);
    snd_seq_queue_tempo_set_tempo(t, 60000000 / tempo);
    snd_seq_queue_tempo_set_ppq(t, division);
    snd_seq_set_queue_tempo(seq, seq_queue, t);

    tps = ( (double) tempo * (double) division ) / 60.0;
    threadQueueTicks = (int) ceil(tps / (double) THREAD_QUEUE_INTERVAL);

    if (queueRunning) {
        snd_seq_start_queue(seq, seq_queue, NULL);
        while ((result = snd_seq_drain_output(seq)) > 0) ;
        if (result < 0) {
            fprintf(stderr, "ALSA could not drain output: err %d\n", result);
        }
    }
}
예제 #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
예제 #3
0
/*
 * Stop the queue
 */
void SeqContext::seq_stop_queue()
{
	snd_seq_stop_queue(handle, queue, 0);

	if( verbose ) fprintf(stderr, "Queue stopped\n");

}
예제 #4
0
void JVlibForm::close_seq() {
  if (!seq) return;
  snd_seq_stop_queue(seq,queue,NULL);
  snd_seq_drop_output(seq);
  snd_seq_drain_output(seq);
  snd_seq_close(seq);
  seq = 0;
}
예제 #5
0
파일: pmlinuxalsa.c 프로젝트: RTcmix/RTcmix
static void alsa_unuse_queue(void)
{
    if (--queue_used == 0) {
        snd_seq_stop_queue(seq, queue, NULL);
        snd_seq_drain_output(seq);
        snd_seq_free_queue(seq, queue);
        VERBOSE printf("queue freed\n");
    }
}
예제 #6
0
void MidiQueue::stop()
{
	snd_seq_stop_queue(_sequencer, _id, nullptr);
	int result = snd_seq_drain_output(_sequencer);
	if (result < 0)
	{
		std::cerr << "MidiQueue::stop error:" << snd_strerror(result) << std::endl;
	}
}
예제 #7
0
파일: alsaseq.c 프로젝트: bgribble/mfp
static PyObject *
alsaseq_stop(PyObject *self /* Not used */, PyObject *args)
{
	if (!PyArg_ParseTuple(args, "" ))
		return NULL;

        snd_seq_stop_queue(seq_handle, queue_id, NULL);
        snd_seq_drain_output(seq_handle);

	Py_INCREF(Py_None);
	return Py_None;
}
예제 #8
0
void
mastermidibus::stop ()
{
    automutex locker(m_mutex);
    for (int i = 0; i < m_num_out_buses; ++i)
        m_buses_out[i]->stop();

#ifdef SEQ64_HAVE_LIBASOUND
    snd_seq_drain_output(m_alsa_seq);
    snd_seq_sync_output_queue(m_alsa_seq);
    snd_seq_stop_queue(m_alsa_seq, m_queue, NULL);  /* start timer */
#endif
}
예제 #9
0
MidiAlsaSeq::~MidiAlsaSeq()
{
	if( isRunning() )
	{
		m_quit = true;
		wait( EventPollTimeOut*2 );

		m_seqMutex.lock();
		snd_seq_stop_queue( m_seqHandle, m_queueID, NULL );
		snd_seq_free_queue( m_seqHandle, m_queueID );
		snd_seq_close( m_seqHandle );
		m_seqMutex.unlock();
	}
}
예제 #10
0
파일: midibus.cpp 프로젝트: vext01/seq24
void 
mastermidibus::stop()
{
    lock();

    for ( int i=0; i < m_num_out_buses; i++ )
        m_buses_out[i]->stop();


    snd_seq_drain_output( m_alsa_seq );
    snd_seq_sync_output_queue( m_alsa_seq );

    /* start timer */
    snd_seq_stop_queue( m_alsa_seq, m_queue, NULL );
    unlock();
}
예제 #11
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
예제 #12
0
파일: midibus.cpp 프로젝트: vext01/seq24
mastermidibus::~mastermidibus()
{
    for ( int i=0; i<m_num_out_buses; i++ )
	delete m_buses_out[i];

    snd_seq_event_t ev;

    /* kill timer */
    snd_seq_ev_clear(&ev);

    snd_seq_stop_queue( m_alsa_seq, m_queue, &ev );
    snd_seq_free_queue( m_alsa_seq, m_queue );

    /* close client */
    snd_seq_close( m_alsa_seq );

}
예제 #13
0
파일: alsaseq.c 프로젝트: ppaez/alsaseq
static PyObject *
alsaseq_stop(PyObject *self /* Not used */, PyObject *args)
{
	if (!PyArg_ParseTuple(args, "" ))
		return NULL;

        if (!seq_handle) {
                PyErr_SetString(PyExc_RuntimeError, "Must initialize module with alsaseq.client() before using it");
                return NULL;
        }

        snd_seq_stop_queue(seq_handle, queue_id, NULL);
        snd_seq_drain_output(seq_handle);

	Py_INCREF(Py_None);
	return Py_None;
}
예제 #14
0
mastermidibus::~mastermidibus ()
{
    for (int i = 0; i < m_num_out_buses; i++)
    {
        if (not_nullptr(m_buses_out[i]))
        {
            delete m_buses_out[i];
            m_buses_out[i] = nullptr;
        }
    }
#ifdef HAVE_LIBASOUND
    snd_seq_event_t ev;
    snd_seq_ev_clear(&ev);                          /* kill timer */
    snd_seq_stop_queue(m_alsa_seq, m_queue, &ev);
    snd_seq_free_queue(m_alsa_seq, m_queue);
    snd_seq_close(m_alsa_seq);                      /* close client */
#endif
}
예제 #15
0
mastermidibus::~mastermidibus ()
{
    for (int i = 0; i < m_num_out_buses; ++i)
    {
        if (not_nullptr(m_buses_out[i]))
        {
            delete m_buses_out[i];
            m_buses_out[i] = nullptr;
        }
    }
    for (int i = 0; i < m_num_in_buses; ++i)
    {
        if (not_nullptr(m_buses_in[i]))
        {
            delete m_buses_in[i];
            m_buses_in[i] = nullptr;
        }
    }

#ifdef SEQ64_HAVE_LIBASOUND
    snd_seq_event_t ev;
    snd_seq_ev_clear(&ev);                          /* kill timer           */
    snd_seq_stop_queue(m_alsa_seq, m_queue, &ev);
    snd_seq_free_queue(m_alsa_seq, m_queue);
    snd_seq_close(m_alsa_seq);                      /* close client         */
    (void) snd_config_update_free_global();         /* additional cleanup   */
#endif

    /*
     * Still more cleanup, not in seq24.
     */

    if (not_nullptr(m_poll_descriptors))
    {
        delete [] m_poll_descriptors;
        m_poll_descriptors = nullptr;
    }
    if (not_nullptr(m_bus_announce))
    {
        delete m_bus_announce;
        m_bus_announce = nullptr;
    }
}
예제 #16
0
int ALSADrv_MIDI_StartPlayback(void (*service)(void))
{
    int result;
    
    ALSADrv_MIDI_HaltPlayback();

    threadService = service;
    threadQuit = 0;

    if (!queueRunning) {
        result = snd_seq_start_queue(seq, seq_queue, NULL);
        if (result < 0) {
            fprintf(stderr, "ALSA snd_seq_start_queue err %d\n", result);
            return ALSAErr_StartQueue;
        }

        while ((result = snd_seq_drain_output(seq)) > 0) ;
        if (result < 0) {
            fprintf(stderr, "ALSA could not drain output: err %d\n", result);
        }
    }

    queueRunning = 1;

    if (pthread_create(&thread, NULL, threadProc, NULL)) {
        fprintf(stderr, "ALSA pthread_create returned error\n");

        snd_seq_stop_queue(seq, seq_queue, NULL);
        while ((result = snd_seq_drain_output(seq)) > 0) ;
        if (result < 0) {
            fprintf(stderr, "ALSA could not drain output: err %d\n", result);
        }
        queueRunning = 0;
        
        return ALSAErr_PlayThread;
    }

    threadRunning = 1;

    return 0;
}