コード例 #1
0
ファイル: rtobject.c プロジェクト: jacob/soundtank
int rtobject_update_alsa_seq_port_name(rtobject_t* rtobj){
  snd_seq_port_info_t* port_info_ptr;
  int port_id;
  char *ret;
  
  port_id = rtobject_get_address(rtobj);
  if (port_id < 0){
    return -1;
  }
  if (!port_id)
    printf("modifying master path ALSA seq port !\n");
  
  ret = rtobject_get_absolute_pathname(rtobj);
    
  /*create an empty port descriptor structure*/
  if ((snd_seq_port_info_malloc(&port_info_ptr)) < 0)
    return -1;
  
  /*set port id*/
  snd_seq_port_info_set_port(port_info_ptr, port_id);
  
  /*set port name*/
  snd_seq_port_info_set_name(port_info_ptr, ret);
  
  /*set capabilities*/
  snd_seq_port_info_set_capability(port_info_ptr,\
				   SND_SEQ_PORT_CAP_WRITE|\
				   SND_SEQ_PORT_CAP_SUBS_WRITE);
  
  /*set type*/
  snd_seq_port_info_set_type(port_info_ptr, SND_SEQ_PORT_TYPE_MIDI_GENERIC);
  
  /*set the port info in sequencer*/
  if (snd_seq_set_port_info(alsa_seq_client_handle, port_id, port_info_ptr) > 0){
    printf("error: couldn't update port info of object being moved\n");
    return -1;
  }
  
  /*free port descriptor structure*/
  snd_seq_port_info_free(port_info_ptr);
    
  free(ret);

  /*recursively update names of member objects for signal paths*/
  if (RTOBJECT_MAJOR_TYPE_SIGNAL_PATH == rtobject_get_major_type(rtobj)){
    node_t *temp_node;

    for (temp_node = ((signal_path_t*)rtobj->imp_struct)->object_list;\
	   temp_node; \
	   temp_node = temp_node->next){

      rtobject_update_alsa_seq_port_name((rtobject_t*)temp_node->data);
	
    }

  }
       
  return 0;
}
コード例 #2
0
ファイル: alsaseq.c プロジェクト: bgribble/mfp
static PyObject *
alsaseq_client(PyObject *self /* Not used */, PyObject *args)
{
  const char * client_name;

  if (!PyArg_ParseTuple(args, "siii", &client_name, &ninputports, &noutputports, &createqueue ) )
		return NULL;

  if ( ninputports > maximum_nports || noutputports > maximum_nports ) {
    printf( "Only %d ports of each are allowed.\n", maximum_nports );
    exit( 1 );
    }

  int portid, n;

  if (snd_seq_open(&seq_handle, "default", SND_SEQ_OPEN_DUPLEX, 0) < 0) {
    fprintf(stderr, "Error creating ALSA client.\n");
    exit(1);
  }
  snd_seq_set_client_name(seq_handle, client_name );

  if ( createqueue )
      queue_id = snd_seq_alloc_queue(seq_handle);
  else
      queue_id = SND_SEQ_QUEUE_DIRECT;

  for ( n=0; n < ninputports; n++ ) {
    if (( portid = snd_seq_create_simple_port(seq_handle, "Input port",
            SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE,
            SND_SEQ_PORT_TYPE_APPLICATION)) < 0) {
    fprintf(stderr, "Error creating input port %d.\n", n );
    exit(1);
    }
    if( createqueue ) {
      /* set timestamp info of port  */
      snd_seq_port_info_t *pinfo;
      snd_seq_port_info_alloca(&pinfo);
      snd_seq_get_port_info( seq_handle, portid, pinfo );
      snd_seq_port_info_set_timestamping(pinfo, 1);
      snd_seq_port_info_set_timestamp_queue(pinfo, queue_id );
      snd_seq_port_info_set_timestamp_real( pinfo, 1 );
      snd_seq_set_port_info( seq_handle, portid, pinfo );
    }
  }

  for ( n=0; n < noutputports; n++ ) {
    if (( portid = snd_seq_create_simple_port(seq_handle, "Output port",
            SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ,
            SND_SEQ_PORT_TYPE_APPLICATION)) < 0) {
      fprintf(stderr, "Error creating output port %d.\n", n );
      exit(1);
    }
  }
    firstoutputport = ninputports;
    lastoutputport  = noutputports + ninputports - 1;

    Py_INCREF(Py_None);
    return Py_None;
}
コード例 #3
0
 void MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterName::OnSetValue(String s) throw (Exception) {
     if (s.size() > 16) throw Exception("Name too long for ALSA MIDI input port (max. 16 characters)");
     snd_seq_port_info_t* hInfo;
     snd_seq_port_info_malloc(&hInfo);
     snd_seq_get_port_info(((MidiInputDeviceAlsa*)pPort->GetDevice())->hAlsaSeq, pPort->GetPortNumber(), hInfo);
     snd_seq_port_info_set_name(hInfo, s.c_str());
     snd_seq_set_port_info(((MidiInputDeviceAlsa*)pPort->GetDevice())->hAlsaSeq, pPort->GetPortNumber(), hInfo);
     snd_seq_port_info_free(hInfo);
 }
コード例 #4
0
ファイル: aseq.c プロジェクト: supergilbert/midilooper
void aseq_output_set_name(void *addr, const char *name)
{
  aseq_output_t *output = (aseq_output_t *) addr;
  int err = 0;

  snd_seq_port_info_set_name(output->info, name);
  err = snd_seq_set_port_info(output->handle, output->port, output->info);
  if (0 != err)
    output_error("problem while setting alsa port info\n%s\n",
                 snd_strerror(err));
}
コード例 #5
0
void MidiAlsaSeq::applyPortName( MidiPort * _port )
{
	m_seqMutex.lock();

	for( int i = 0; i < 2; ++i )
	{
		if( m_portIDs[_port][i] == -1 )
		{
			continue;
		}
		snd_seq_port_info_t * port_info;
		snd_seq_port_info_malloc( &port_info );
		snd_seq_get_port_info( m_seqHandle, m_portIDs[_port][i],
							port_info );
		snd_seq_port_info_set_name( port_info,
				_port->displayName().toUtf8().constData() );
		snd_seq_set_port_info( m_seqHandle, m_portIDs[_port][i],
							port_info );
		snd_seq_port_info_free( port_info );
	}

	m_seqMutex.unlock();
}
コード例 #6
0
void MidiAlsaSeq::applyPortMode( MidiPort * _port )
{
	m_seqMutex.lock();

	// determine port-capabilities
	unsigned int caps[2] = { 0, 0 };

	switch( _port->mode() )
	{
		case MidiPort::Duplex:
			caps[1] |= SND_SEQ_PORT_CAP_READ |
						SND_SEQ_PORT_CAP_SUBS_READ;

		case MidiPort::Input:
			caps[0] |= SND_SEQ_PORT_CAP_WRITE |
						SND_SEQ_PORT_CAP_SUBS_WRITE;
			break;

		case MidiPort::Output:
			caps[1] |= SND_SEQ_PORT_CAP_READ |
						SND_SEQ_PORT_CAP_SUBS_READ;
			break;

		default:
			break;
	}

	for( int i = 0; i < 2; ++i )
	{
		if( caps[i] != 0 )
		{
			// no port there yet?
			if( m_portIDs[_port][i] == -1 )
			{
				// then create one;
				m_portIDs[_port][i] =
						snd_seq_create_simple_port(
							m_seqHandle,
				_port->displayName().toUtf8().constData(),
							caps[i],
						SND_SEQ_PORT_TYPE_MIDI_GENERIC |
						SND_SEQ_PORT_TYPE_APPLICATION );
				continue;
			}
			snd_seq_port_info_t * port_info;
			snd_seq_port_info_malloc( &port_info );
			snd_seq_get_port_info( m_seqHandle, m_portIDs[_port][i],
							port_info );
			snd_seq_port_info_set_capability( port_info, caps[i] );
			snd_seq_set_port_info( m_seqHandle, m_portIDs[_port][i],
							port_info );
			snd_seq_port_info_free( port_info );
		}
		// still a port there although no caps? ( = dummy port)
		else if( m_portIDs[_port][i] != -1 )
		{
			// then remove this port
			snd_seq_delete_simple_port( m_seqHandle,
							m_portIDs[_port][i] );
			m_portIDs[_port][i] = -1;
		}
	}

	m_seqMutex.unlock();
}