Ejemplo n.º 1
0
void SeqDriver::procEvents()
{
    int l1;
    snd_seq_event_t *evIn, evOut;
    bool outOfRange = false;
    bool unmatched = false;
    MidiMap* mm;

    do {
        snd_seq_event_input(seq_handle, &evIn);
        emit midiEvent(evIn);
        unmatched = true;
        for(l1 = 0; l1 < midiMapList->count(); l1++) {
            mm = midiMapList->at(l1);
            if (mm->isMap(evIn)) {
                unmatched = false;
                mm->doMap(evIn, &evOut, &outOfRange);
                if (!outOfRange) {
                    snd_seq_ev_set_subs(&evOut);  
                    snd_seq_ev_set_direct(&evOut);
                    snd_seq_ev_set_source(&evOut, portid_out[mm->portOut]);
                    snd_seq_event_output_direct(seq_handle, &evOut);
                }  
            }
        }
        if (!discardUnmatched && unmatched) {
            snd_seq_ev_set_subs(evIn);  
            snd_seq_ev_set_direct(evIn);
            snd_seq_ev_set_source(evIn, portid_out[portUnmatched]);
            snd_seq_event_output_direct(seq_handle, evIn);
        }
    } while (snd_seq_event_input_pending(seq_handle, 0) > 0);  
}
Ejemplo n.º 2
0
// This splits the Midi events from one channel to another two channels
void Spliter::midievents(){
    snd_seq_event_t *midievent;
    midievent=NULL;
    snd_seq_event_input(midi_in,&midievent);
    
    if (midievent==NULL) return;
    if  ((midievent->type==SND_SEQ_EVENT_NOTEON)||(midievent->type==SND_SEQ_EVENT_NOTEOFF)){
	int cmdchan=midievent->data.note.channel;
	if (cmdchan==Pchin){
	snd_seq_ev_set_subs(midievent);  
	snd_seq_ev_set_direct(midievent);
	if (midievent->data.note.note<Psplitpoint) {
	    midievent->data.note.channel=Pchout1;
	    int tmp=midievent->data.note.note;
	    tmp+=Poct1*12;if (tmp>127) tmp=127;if (tmp<0) tmp=0;
	    midievent->data.note.note=tmp;
	    } else {
	    midievent->data.note.channel=Pchout2;
	    int tmp=midievent->data.note.note;
	    tmp+=Poct2*12;if (tmp>127) tmp=127;if (tmp<0) tmp=0;
	    midievent->data.note.note=tmp;
	    };
	snd_seq_event_output_direct(midi_out,midievent);
	} else {
	snd_seq_ev_set_subs(midievent);  
	snd_seq_ev_set_direct(midievent);
	snd_seq_event_output_direct(midi_out,midievent);
	};
				    
    };
    snd_seq_free_event(midievent);
};
Ejemplo n.º 3
0
void
midibus::continue_from( long a_tick )
{
    /* tell the device that we are going to start at a certain position */
    long pp16th = (c_ppqn / 4);

    long leftover = ( a_tick % pp16th );
    long beats = ( a_tick / pp16th );

    long starting_tick = a_tick - leftover;

    /* was there anything left?, then wait for next beat (16th note) to start clocking */
    if ( leftover > 0)
    {
        starting_tick += pp16th;
    }
    //printf ( "continue_from leftover[%ld] starting_tick[%ld]\n", leftover, starting_tick );

    m_lasttick = starting_tick - 1;    

    if ( m_clock_type != e_clock_off )
    {
        //printf( "control value %ld\n",  beats);

        snd_seq_event_t evc;
        snd_seq_event_t ev;

        ev.type = SND_SEQ_EVENT_CONTINUE;
        evc.type = SND_SEQ_EVENT_SONGPOS;
        evc.data.control.value = beats;
        snd_seq_ev_set_fixed( &ev );    
        snd_seq_ev_set_fixed( &evc );

        snd_seq_ev_set_priority( &ev, 1 );
        snd_seq_ev_set_priority( &evc, 1 );

        /* set source */
        snd_seq_ev_set_source(&evc, m_local_addr_port );
        snd_seq_ev_set_subs(&evc);
        snd_seq_ev_set_source(&ev, m_local_addr_port );
        snd_seq_ev_set_subs(&ev);

        // its immediate 
        snd_seq_ev_set_direct( &ev );
        snd_seq_ev_set_direct( &evc );

        /* pump it into the queue */
        snd_seq_event_output(m_seq, &evc);
        flush();
        snd_seq_event_output(m_seq, &ev);
    }
}
    void sendMessageNow (const MidiMessage& message)
    {
        if (message.getRawDataSize() > maxEventSize)
        {
            maxEventSize = message.getRawDataSize();
            snd_midi_event_free (midiParser);
            snd_midi_event_new (maxEventSize, &midiParser);
        }

        snd_seq_event_t event;
        snd_seq_ev_clear (&event);

        snd_midi_event_encode (midiParser,
                               message.getRawData(),
                               message.getRawDataSize(),
                               &event);

        snd_midi_event_reset_encode (midiParser);

        snd_seq_ev_set_source (&event, 0);
        snd_seq_ev_set_subs (&event);
        snd_seq_ev_set_direct (&event);

        snd_seq_event_output (seqHandle, &event);
        snd_seq_drain_output (seqHandle);
    }
Ejemplo n.º 5
0
void MIDIDevice::feedBack(t_input_channel channel, t_input_value value)
{
	/* MIDI devices can have only 128 notes or controllers */
	if (channel < 128)
	{
		snd_seq_event_t ev;
		MIDIInput* plugin;

		plugin = static_cast<MIDIInput*> (parent());
		Q_ASSERT(plugin != NULL);
		Q_ASSERT(plugin->alsa() != NULL);
		Q_ASSERT(m_address != NULL);

		/* Setup an event structure */
		snd_seq_ev_clear(&ev);
		snd_seq_ev_set_dest(&ev, m_address->client, m_address->port);
		snd_seq_ev_set_subs(&ev);
		snd_seq_ev_set_direct(&ev);

		/* Send control change, channel 1 (0) */
		snd_seq_ev_set_controller(&ev, 0, channel, value >> 1);
		snd_seq_event_output(plugin->alsa(), &ev);
		snd_seq_drain_output(plugin->alsa());

		/* Send note on/off, channel 1 (0) */
		if (value == 0)
			snd_seq_ev_set_noteoff(&ev, 0, channel, 0);
		else
			snd_seq_ev_set_noteon(&ev, 0, channel, value >> 1);
		snd_seq_event_output(plugin->alsa(), &ev);
		snd_seq_drain_output(plugin->alsa());
	}
Ejemplo n.º 6
0
void* lp2midi(void* nothing)
{
    printf("waiting for launchpad events\n");
	snd_seq_event_t event;
    
    while (1) {
		// wait for an event
		lp_receive(lp);

		// setup
		snd_seq_ev_clear(&event);
		snd_seq_ev_set_source(&event, midi_out);	// set the output port number
		snd_seq_ev_set_subs(&event);		// broadcast to subscribers
		
		// fill the event
		switch(lp->event[0]) {
		case NOTE:
			snd_seq_ev_set_noteon(&event, 0, lp->event[1], lp->event[2]);
			break;
		case CTRL:
			snd_seq_ev_set_controller(&event, 0, lp->event[1], lp->event[2]);
			break;
		}
		
		// send now
		snd_seq_ev_set_direct(&event);		
		snd_seq_event_output(midi_client, &event);
		snd_seq_drain_output(midi_client);
    }
}
Ejemplo n.º 7
0
void stop_midireceiver (JackVST *jvst)
{
	int err; 
	snd_seq_event_t event;
	snd_seq_t *seq2 = create_sequencer ("jfstquit", true);
	
	jvst->midiquit = 1;
	
	snd_seq_connect_to (seq2, 0, snd_seq_client_id (jvst->seq),0);
	snd_seq_ev_clear      (&event);
	snd_seq_ev_set_direct (&event);
	snd_seq_ev_set_subs   (&event);
	snd_seq_ev_set_source (&event, 0);
	snd_seq_ev_set_controller (&event,1,0x80,50);
	
	if ((err = snd_seq_event_output (seq2, &event)) < 0) {
		fst_error ("cannot send stop event to midi thread: %s\n",
			   snd_strerror (err));
	}

	snd_seq_drain_output (seq2);
	snd_seq_close (seq2);
	pthread_join (jvst->midi_thread,NULL);
	snd_seq_close (jvst->seq);
}
Ejemplo n.º 8
0
void
midibus::play (event * a_e24, unsigned char a_channel)
{
#ifdef HAVE_LIBASOUND
    automutex locker(m_mutex);
    snd_seq_event_t ev;
    snd_midi_event_t *midi_ev;      /* ALSA MIDI parser   */
    unsigned char buffer[3];        /* temp for MIDI data */

    /* fill buffer and set midi channel */

    buffer[0] = a_e24->get_status();
    buffer[0] += (a_channel & 0x0F);
    a_e24->get_data(&buffer[1], &buffer[2]);
    snd_midi_event_new(10, &midi_ev);

    /* clear event */

    snd_seq_ev_clear(&ev);
    snd_midi_event_encode(midi_ev, buffer, 3, &ev);
    snd_midi_event_free(midi_ev);

    /* set source */

    snd_seq_ev_set_source(&ev, m_local_addr_port);
    snd_seq_ev_set_subs(&ev);
    snd_seq_ev_set_direct(&ev);     // its immediate

    /* pump it into the queue */

    snd_seq_event_output(m_seq, &ev);
#endif  // HAVE_LIBASOUND
}
Ejemplo n.º 9
0
void MIDIDevice::outputDMX(const QByteArray& universe)
{
    MIDIOut* plugin = static_cast<MIDIOut*> (parent());
    Q_ASSERT(plugin != NULL);
    Q_ASSERT(plugin->alsa() != NULL);
    Q_ASSERT(m_address != NULL);

    /* Setup a common event structure for all values */
    snd_seq_event_t ev;
    snd_seq_ev_clear(&ev);
    snd_seq_ev_set_dest(&ev, m_address->client, m_address->port);
    snd_seq_ev_set_subs(&ev);
    snd_seq_ev_set_direct(&ev);

    /* Since MIDI devices can have only 128 real channels, we don't
       attempt to write more than that */

    for (unsigned char channel = 0; channel < MAX_MIDI_DMX_CHANNELS;
            channel++)
    {
        /* Scale 0-255 to 0-127 */
        char scaled = DMX2MIDI(universe[channel]);

        /* Since MIDI is so slow, we only send values that are
           	   actually changed. */
        if (m_values[channel] == scaled)
            continue;

        /* Store the changed MIDI value */
        m_values[channel] = scaled;

        if (mode() == Note)
        {
            if (scaled == 0)
            {
                /* 0 is sent as a note off command */
                snd_seq_ev_set_noteoff(&ev, midiChannel(),
                                       channel, scaled);
            }
            else
            {
                /* 1-127 is sent as note on command */
                snd_seq_ev_set_noteon(&ev, midiChannel(),
                                      channel, scaled);
            }

            snd_seq_event_output(plugin->alsa(), &ev);
        }
        else
        {
            /* Control change */
            snd_seq_ev_set_controller(&ev, midiChannel(),
                                      channel, scaled);
            snd_seq_event_output_buffer(plugin->alsa(), &ev);
        }
    }

    /* Make sure that all values go to the MIDI endpoint */
    snd_seq_drain_output(plugin->alsa());
}
Ejemplo n.º 10
0
    void sendMessageNow (const MidiMessage& message)
    {
        if (message.getRawDataSize() > maxEventSize)
        {
            maxEventSize = message.getRawDataSize();
            snd_midi_event_free (midiParser);
            snd_midi_event_new (maxEventSize, &midiParser);
        }

        snd_seq_event_t event;
        snd_seq_ev_clear (&event);

        long numBytes = (long) message.getRawDataSize();
        const uint8* data = message.getRawData();

        while (numBytes > 0)
        {
            const long numSent = snd_midi_event_encode (midiParser, data, numBytes, &event);
            if (numSent <= 0)
                break;

            numBytes -= numSent;
            data += numSent;

            snd_seq_ev_set_source (&event, 0);
            snd_seq_ev_set_subs (&event);
            snd_seq_ev_set_direct (&event);

            snd_seq_event_output (seqHandle, &event);
        }

        snd_seq_drain_output (seqHandle);
        snd_midi_event_reset_encode (midiParser);
    }
Ejemplo n.º 11
0
void aubio_midi_direct_output(aubio_midi_driver_t * d, aubio_midi_event_t * event) 
{
    aubio_alsa_seq_driver_t* dev = (aubio_alsa_seq_driver_t*) d;
    switch(event->type) 
    {
        case NOTE_ON:
            ev.type = SND_SEQ_EVENT_NOTEON;
            ev.data.note.channel  = event->channel;
            ev.data.note.note     = event->param1;
            ev.data.note.velocity = event->param2;
            //AUBIO_ERR( "NOTE_ON %d\n", event->param1);
            break;
        case NOTE_OFF:
            ev.type = SND_SEQ_EVENT_NOTEOFF;
            ev.data.note.channel  = event->channel;
            ev.data.note.note     = event->param1;
            ev.data.note.velocity = event->param2;
            //AUBIO_ERR( "NOTE_OFF %d\n", event->param1);
            break;
        default:
            break;
    }
    if (ev.type == SND_SEQ_EVENT_NOTEOFF || ev.type == SND_SEQ_EVENT_NOTEON ) { 
        snd_seq_ev_set_subs(&ev);
        snd_seq_ev_set_direct(&ev);
        snd_seq_ev_set_source(&ev, dev->seq_port);
        snd_seq_event_output_direct(dev->seq_handle, &ev);
    }
}
Ejemplo n.º 12
0
void qxgeditMidiDevice::sendSysex (
	unsigned char *pSysex, unsigned short iSysex ) const
{
#ifdef CONFIG_DEBUG
	fprintf(stderr, "qxgeditMidiDevice::sendSysex(%p, %u)", pSysex, iSysex);
	fprintf(stderr, " sysex {");
	for (unsigned short i = 0; i < iSysex; ++i)
		fprintf(stderr, " %02x", pSysex[i]);
	fprintf(stderr, " }\n");
#endif

	// Don't do anything else if engine
	// has not been activated...
	if (m_pAlsaSeq == NULL)
		return;

	// Initialize sequencer event...
	snd_seq_event_t ev;
	snd_seq_ev_clear(&ev);

	// Addressing...
	snd_seq_ev_set_source(&ev, m_iAlsaPort);
	snd_seq_ev_set_subs(&ev);

	// The event will be direct...
	snd_seq_ev_set_direct(&ev);

	// Just set SYSEX stuff and send it out..
	ev.type = SND_SEQ_EVENT_SYSEX;
	snd_seq_ev_set_sysex(&ev, iSysex, pSysex);
	snd_seq_event_output_direct(m_pAlsaSeq, &ev);
}
Ejemplo n.º 13
0
static void 
note_on(int note, real_t power) {

  snd_seq_event_t ev;

  if (debug>1) 
	fprintf(stderr, "midimatch: (%ld) note on:  note:%-3d p:%.2f name:%s@%d\n", 
			absolute_time, note, power, 
			midi_notename(note), midi_octave(note));
  else if (debug>0) 
	fprintf(stderr, ".");
 
  stats_note_ons ++;
 
  act_freq[note] = 1;
  if (midi_file != NULL ) {
	midi_write_note_event(0x90 | midi_channel, note, 100, midi_file);
  }

  if ( use_sequencer ) {
	snd_seq_ev_clear(&ev);
	snd_seq_ev_set_source(&ev, 0);
	snd_seq_ev_set_subs(&ev);
	snd_seq_ev_set_direct(&ev);
  
	snd_seq_ev_set_noteon(&ev, midi_channel, note, 100) ;
	
	snd_seq_event_output(midi_sequencer, &ev);
	snd_seq_drain_output(midi_sequencer);
  }
}
Ejemplo n.º 14
0
static void
note_off(int note, real_t power) {

  snd_seq_event_t ev;

  if (debug>2) 
	fprintf(stderr, "midimatch: (%ld) note off: note:%-3d p:%.2f maxp:%0.2f\n", 
			absolute_time, note, power, act_freq[note]);
  

  act_freq[note] = 0.0f;
  if (midi_file != NULL )
	midi_write_note_event(0x80 | midi_channel, note, 100, midi_file);

  if ( use_sequencer ) {
	snd_seq_ev_clear(&ev);
	snd_seq_ev_set_source(&ev, 0);
	snd_seq_ev_set_subs(&ev);
	snd_seq_ev_set_direct(&ev);

	snd_seq_ev_set_noteoff(&ev, midi_channel, note, 100) ;
	
	snd_seq_event_output(midi_sequencer, &ev);
	snd_seq_drain_output(midi_sequencer);
  }
}
Ejemplo n.º 15
0
void
midibus::clock (midipulse tick)
{
#ifdef SEQ64_HAVE_LIBASOUND
    automutex locker(m_mutex);
    if (m_clock_type != e_clock_off)
    {
        bool done = m_lasttick >= tick;
        int ct = clock_ticks_from_ppqn(m_ppqn);         /* ppqn / 24    */
        while (! done)
        {
            ++m_lasttick;
            done = m_lasttick >= tick;
            if ((m_lasttick % ct) == 0)                 /* tick time?           */
            {
                /*
                 * Set the event tag to 127 so the sequences won't remove it.
                 */

                snd_seq_event_t ev;
                ev.type = SND_SEQ_EVENT_CLOCK;
                ev.tag = 127;
                snd_seq_ev_set_fixed(&ev);
                snd_seq_ev_set_priority(&ev, 1);
                snd_seq_ev_set_source(&ev, m_local_addr_port); /* set source    */
                snd_seq_ev_set_subs(&ev);
                snd_seq_ev_set_direct(&ev);             /* it's immediate       */
                snd_seq_event_output(m_seq, &ev);       /* pump it into queue   */
            }
        }
        flush();            /* and send out */
    }
#endif  // SEQ64_HAVE_LIBASOUND
}
Ejemplo n.º 16
0
void send_event() {
  snd_seq_ev_set_direct(&ev);
  snd_seq_ev_set_source(&ev, my_port);
  snd_seq_ev_set_dest(&ev, seq_client, seq_port);
  snd_seq_event_output(seq_handle, &ev);
  snd_seq_drain_output(seq_handle);
}
Ejemplo n.º 17
0
void 
midibus::stop()
{

    m_lasttick = -1;

    if ( m_clock_type != e_clock_off ){   
	
	snd_seq_event_t ev;
	
	ev.type = SND_SEQ_EVENT_STOP;
	snd_seq_ev_set_fixed( &ev );
	
	snd_seq_ev_set_priority( &ev, 1 );
	
	/* set source */
	snd_seq_ev_set_source(&ev, m_local_addr_port );
	snd_seq_ev_set_subs(&ev);
	
	// its immediate 
	snd_seq_ev_set_direct( &ev );
	
	/* pump it into the queue */
	snd_seq_event_output(m_seq, &ev);
	
    }
}
Ejemplo n.º 18
0
void JVlibForm::on_System_MIDI_progressBar_sliderReleased() {
    if (!System_PauseMidi_button->isChecked()) return;
    snd_seq_event_t ev;
    snd_seq_ev_clear(&ev);
    snd_seq_ev_set_direct(&ev);
    snd_seq_get_queue_status(seq, queue, status);
    // reset queue position
    snd_seq_ev_is_tick(&ev);
    snd_seq_ev_set_queue_pos_tick(&ev, queue, 0);
    snd_seq_event_output(seq, &ev);
    snd_seq_drain_output(seq);
    // scan the event queue for the closest tick >= 'x'
    int y = 0;
    for (std::vector<event>::iterator Event=all_events.begin(); Event!=all_events.end(); ++Event)  {
        if (static_cast<int>(Event->tick) >= System_MIDI_progressBar->sliderPosition()) {
            ev.time.tick = Event->tick;
	    event_num = y;
            break;
        }
        y++;
    }
    ev.dest.client = SND_SEQ_CLIENT_SYSTEM;
    ev.dest.port = SND_SEQ_PORT_SYSTEM_TIMER;
    snd_seq_ev_set_queue_pos_tick(&ev, queue, ev.time.tick);
    snd_seq_event_output(seq, &ev);
    snd_seq_drain_output(seq);
    snd_seq_real_time_t *new_time = new snd_seq_real_time_t;
    double x = static_cast<double>(ev.time.tick)/all_events.back().tick;
    new_time->tv_sec = (x*song_length_seconds);
    new_time->tv_nsec = 0;
    snd_seq_ev_set_queue_pos_real(&ev, queue, new_time);
    MIDI_time_display->setText(QString::number(static_cast<int>(new_time->tv_sec)/60).rightJustified(2,'0')+
      ":"+QString::number(static_cast<int>(new_time->tv_sec)%60).rightJustified(2,'0'));
    if (System_PauseMidi_button->isChecked()) return;
}	// end on_System_MIDI_progressBar_sliderReleased
Ejemplo n.º 19
0
void
midibus::continue_from (midipulse tick)
{
#ifdef SEQ64_HAVE_LIBASOUND

    /*
     * Tell the device that we are going to start at a certain position.
     */

    midipulse pp16th = m_ppqn / 4;
    midipulse leftover = tick % pp16th;
    long beats = tick / pp16th;
    midipulse starting_tick = tick - leftover;

    /*
     * Was there anything left? Then wait for next beat (16th note) to
     * start clocking.
     */

    if (leftover > 0)
        starting_tick += pp16th;

    m_lasttick = starting_tick - 1;
    if (m_clock_type != e_clock_off)
    {
        snd_seq_event_t ev;
        ev.type = SND_SEQ_EVENT_CONTINUE;

        snd_seq_event_t evc;
        evc.type = SND_SEQ_EVENT_SONGPOS;
        evc.data.control.value = beats;
        snd_seq_ev_set_fixed(&ev);
        snd_seq_ev_set_fixed(&evc);
        snd_seq_ev_set_priority(&ev, 1);
        snd_seq_ev_set_priority(&evc, 1);
        snd_seq_ev_set_source(&evc, m_local_addr_port); /* set the source   */
        snd_seq_ev_set_subs(&evc);
        snd_seq_ev_set_source(&ev, m_local_addr_port);
        snd_seq_ev_set_subs(&ev);
        snd_seq_ev_set_direct(&ev);                     /* it's immediate   */
        snd_seq_ev_set_direct(&evc);
        snd_seq_event_output(m_seq, &evc);              /* pump into queue  */
        flush();
        snd_seq_event_output(m_seq, &ev);
    }
#endif  // SEQ64_HAVE_LIBASOUND
}
Ejemplo n.º 20
0
//  FUNCTIONS
void JVlibForm::send_data(char * buf,int data_size) {
    snd_seq_event_t ev;
    snd_seq_ev_clear(&ev);
    snd_seq_ev_set_direct(&ev);
    ev.queue = SND_SEQ_QUEUE_DIRECT;
    ev.type = SND_SEQ_EVENT_CONTROLLER;
    ev.dest = ports[0];
    ev.data.control.channel = buf[0];
    if (data_size>1)
      ev.data.control.param = buf[1];
    if (data_size==3)
      ev.data.control.value = buf[2];
    snd_seq_ev_set_fixed(&ev);
    snd_seq_ev_set_direct(&ev);
    snd_seq_event_output_direct(seq, &ev);
    snd_seq_drain_output(seq);
}   // end send_data
Ejemplo n.º 21
0
void MidiDriver_ALSA::send_event(int do_flush) {
	snd_seq_ev_set_direct(&ev);
	snd_seq_ev_set_source(&ev, my_port);
	snd_seq_ev_set_dest(&ev, seq_client, seq_port);

	snd_seq_event_output(seq_handle, &ev);
	if (do_flush)
		snd_seq_flush_output(seq_handle);
}
Ejemplo n.º 22
0
static void send()
{
    snd_seq_ev_set_source(&ev, readable_port);
    snd_seq_ev_set_dest(&ev, dest_client_id, 0);
    snd_seq_ev_set_direct(&ev);

    snd_seq_event_output(seq, &ev);
    snd_seq_drain_output(seq);
}
Ejemplo n.º 23
0
// generates midi clock
void
midibus::clock( long a_tick )
{

    lock();

    if ( m_clock_type != e_clock_off ){

	bool done = false;
	
	long uptotick = a_tick;
	
	if ( m_lasttick >= uptotick )
	    done = true;
	
	while ( !done ){
	    
	    m_lasttick++;
	    
	    if ( m_lasttick >= uptotick )
		done = true;
	    
	    /* tick time? */
	    if ( m_lasttick % ( c_ppqn / 24 ) == 0 ){
		
		snd_seq_event_t ev;
		
		ev.type = SND_SEQ_EVENT_CLOCK;
		
		/* set tag to 127 so the sequences
		   wont remove it */
		ev.tag = 127;
		
		snd_seq_ev_set_fixed( &ev );
		
		snd_seq_ev_set_priority( &ev, 1 );
		
		/* set source */
		snd_seq_ev_set_source(&ev, m_local_addr_port );
		snd_seq_ev_set_subs(&ev);
		
		// its immediate 
		snd_seq_ev_set_direct( &ev );
		
		/* pump it into the queue */
		snd_seq_event_output(m_seq, &ev);

	    }
	}
	/* and send out */
	flush();
    }

    unlock();
}
Ejemplo n.º 24
0
/**
 * \brief queue controls - start/stop/continue
 * \param seq sequencer handle
 * \param q queue id to control
 * \param type event type
 * \param value event value
 * \param ev event instance
 *
 * This function sets up general queue control event and sends it.
 * To send at scheduled time, set the schedule in \a ev.
 * If \a ev is NULL, the event is composed locally and sent immediately
 * to the specified queue.  In any cases, you need to call #snd_seq_drain_output()
 * appropriately to feed the event.
 *
 * \sa snd_seq_alloc_queue()
 */
int snd_seq_control_queue(snd_seq_t *seq, int q, int type, int value, snd_seq_event_t *ev)
{
	snd_seq_event_t tmpev;
	if (ev == NULL) {
		snd_seq_ev_clear(&tmpev);
		ev = &tmpev;
		snd_seq_ev_set_direct(ev);
	}
	snd_seq_ev_set_queue_control(ev, type, q, value);
	return snd_seq_event_output(seq, ev);
}
Ejemplo n.º 25
0
void MIDIDevice::feedBack(t_input_channel channel, t_input_value value)
{
	/* MIDI devices can have only 128 notes or controllers */
	if (channel < 128)
	{
		snd_seq_event_t ev;
		MIDIInput* plugin;

		plugin = static_cast<MIDIInput*> (parent());
		Q_ASSERT(plugin != NULL);
		Q_ASSERT(plugin->alsa() != NULL);
		Q_ASSERT(m_address != NULL);

		/* Setup an event structure */
		snd_seq_ev_clear(&ev);
		snd_seq_ev_set_dest(&ev, m_address->client, m_address->port);
		snd_seq_ev_set_subs(&ev);
		snd_seq_ev_set_direct(&ev);

		char scaled = static_cast <char> (SCALE(double(value),
							double(0),
							double(KInputValueMax),
							double(0),
							double(127)));

		if (m_mode == ControlChange)
		{
			/* Send control change */
			snd_seq_ev_set_controller(&ev, midiChannel(),
						  channel, scaled);
			snd_seq_event_output(plugin->alsa(), &ev);
			snd_seq_drain_output(plugin->alsa());
		}
		else
		{
			/* Send note on/off */
			if (value == 0)
			{
				snd_seq_ev_set_noteoff(&ev, midiChannel(),
							channel, scaled);
			}
			else
			{
				snd_seq_ev_set_noteon(&ev, midiChannel(),
							channel, scaled);
			}

			snd_seq_event_output(plugin->alsa(), &ev);
			snd_seq_drain_output(plugin->alsa());
		}
	}
}
Ejemplo n.º 26
0
Archivo: synth.c Proyecto: cassou/harp
void synth_noteStop(synth_t * st,int num, int status)
{
    snd_seq_event_t ev;
    snd_seq_ev_clear(&ev);
    snd_seq_ev_set_direct(&ev);
    snd_seq_ev_set_source(&ev, port_out_id);
    snd_seq_ev_set_subs(&ev);
    //usleep(100000);
    printf("synth_noteStop %d\n", st->runningNote[num]);
    snd_seq_ev_set_noteoff(&ev, st->channel, st->runningNote[num], st->velocity);
    snd_seq_event_output_direct(seq, &ev);
    snd_seq_drain_output(seq);
}
Ejemplo n.º 27
0
void
rimshot_alsa_output_play_note (rimshot_alsa_output_t *output, int channel, int note, unsigned int velocity)
{
    snd_seq_event_t ev;

    snd_seq_ev_clear (&ev);
    snd_seq_ev_set_source (&ev, output->port);
    snd_seq_ev_set_subs (&ev);
    snd_seq_ev_set_direct (&ev);

    snd_seq_ev_set_noteon (&ev, channel, note, velocity);
    snd_seq_event_output_direct (output->seq, &ev);
}
Ejemplo n.º 28
0
Archivo: synth.c Proyecto: cassou/harp
void synth_noteStart(synth_t * st,int num, int status)
{
    snd_seq_event_t ev;
    snd_seq_ev_clear(&ev);
    snd_seq_ev_set_direct(&ev);
    snd_seq_ev_set_source(&ev, port_out_id);
    snd_seq_ev_set_subs(&ev);
    printf("synth_noteStart %d\n", st->btn2note[num]);
    int note = st->btn2note[num]+st->sharp+12*st->octaveUp-12*st->octaveDown;
    st->runningNote[num]=note;
    snd_seq_ev_set_noteon(&ev, st->channel, note, st->velocity);
    snd_seq_event_output_direct(seq, &ev);
    snd_seq_drain_output(seq);
}
Ejemplo n.º 29
0
void pitch_alsa(void* seqq, unsigned char chan, short val)
{
    ALSA_SEQ* seq = (ALSA_SEQ*)seqq;
    snd_seq_event_t ev;

    snd_seq_ev_clear(&ev);
    snd_seq_ev_set_source(&ev, seq->g_port);
    snd_seq_ev_set_subs(&ev);
    snd_seq_ev_set_direct(&ev);

    snd_seq_ev_set_pitchbend(&ev, chan, val);

    snd_seq_event_output(seq->g_seq, &ev);
    snd_seq_drain_output(seq->g_seq);
}
Ejemplo n.º 30
0
/* takes an native event, encodes to alsa event, 
   puts it in the queue */
void 
midibus::play( event *a_e24, unsigned char a_channel )
{
    lock();

  

		snd_seq_event_t ev;
		
		/* alsa midi parser */
		snd_midi_event_t *midi_ev;
		
		/* temp for midi data */
		unsigned char buffer[3];
		
		/* fill buffer and set midi channel */
		buffer[0] = a_e24->get_status();
		buffer[0] += (a_channel & 0x0F);
		
		a_e24->get_data( &buffer[1], &buffer[2] );
		
		snd_midi_event_new( 10, &midi_ev );
		
		/* clear event */
		snd_seq_ev_clear( &ev );
		snd_midi_event_encode( midi_ev,
							   buffer,
							   3,
							   &ev ); 
		
		snd_midi_event_free( midi_ev );
		
		/* set source */
		snd_seq_ev_set_source(&ev, m_local_addr_port );
		snd_seq_ev_set_subs(&ev);
		
		/* set tag unique to each sequence for removal purposes */
		//ev.tag = a_tag;
		
		// its immediate 
		snd_seq_ev_set_direct( &ev );
		
		/* pump it into the queue */
		snd_seq_event_output(m_seq, &ev);
	

    unlock();
}