コード例 #1
0
ファイル: portmidi.cpp プロジェクト: ccmurray/mame
void pm_module::list_midi_devices(void)
{
	int num_devs = Pm_CountDevices();
	const PmDeviceInfo *pmInfo;

	printf("\n");

	if (num_devs == 0)
	{
		printf("No MIDI ports were found\n");
		return;
	}

	printf("MIDI input ports:\n");
	for (int i = 0; i < num_devs; i++)
	{
		pmInfo = Pm_GetDeviceInfo(i);

		if (pmInfo->input)
		{
			printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultInputDeviceID()) ? "(default)" : "");
		}
	}

	printf("\nMIDI output ports:\n");
	for (int i = 0; i < num_devs; i++)
	{
		pmInfo = Pm_GetDeviceInfo(i);

		if (pmInfo->output)
		{
			printf("%s %s\n", pmInfo->name, (i == Pm_GetDefaultOutputDeviceID()) ? "(default)" : "");
		}
	}
}
コード例 #2
0
void MidiSession::openOutputDevice(std::string device)
{
    auto numMidiInputs = Pm_CountDevices();
    auto devices = getDevices();
    
    for(auto i = 0; i < numMidiInputs; i++)
    {
        if(devices[i] == device)
        {
            if(!Pm_GetDeviceInfo(i)->opened)
                error = Pm_OpenOutput(&midiStream, i, nullptr, 3, nullptr, nullptr, 0);
            else
                std::cout<<"Device is already opened"<<std::endl;
            
            if(error != pmNoError)
            {
                std::cout<<"Trying to open device: "<<devices[i]<<std::endl;
                std::cout<<Pm_GetErrorText(error)<<std::endl;
                return;
            }
            
            midiThread = std::thread(&MidiSession::read, this);
            midiThread.detach();
            
            return;
        }
    }
}
コード例 #3
0
ファイル: midi.c プロジェクト: amoweb/RaspberryBoucle
bool midiInit()
{
        Pm_Initialize();

        // Initialize buffer
        nbEventWaiting = 0;
        iEventWaiting = 0;

        int portIn = -1;
        int portOut = -1;
        /* List device information */
        for (int i = 0; i < Pm_CountDevices(); i++) {
                const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
                if ((info->input) || (info->output)) {
                        printf("%d: %s, %s", i, info->interf, info->name);
                        if (info->input) {
                                portIn = i;
                                printf(" (input)");
                        }

                        if (info->output) {
                                portOut = i;
                                printf(" (output)");
                        }
                        printf("\n");
                }
        }

        if(portOut == -1 || portIn == -1) {
                printf("Midi port not found.\r\n");
                return -1;
        }

        return false;
}
コード例 #4
0
void FLiveEditorManager::FindDevices()
{
	//find all our devices
	int NumDevices = Pm_CountDevices(); //needs to remain int (instead of int32) since numbers are derived from TPL that uses int
	for ( int i = 0; i < NumDevices; i++ )
	{
		const PmDeviceInfo *Info = Pm_GetDeviceInfo( i );
		if ( Info->input && !InputConnections.Find(i) )
		{
			PortMidiStream *MIDIStream;
			PmError Error = Pm_OpenInput( &MIDIStream, i, NULL, DEFAULT_BUFFER_SIZE, NULL, NULL );
			if ( Error == pmNoError )
			{
				FLiveEditorDeviceInstance DeviceInstance;
				DeviceInstance.Data.DeviceName = FString(Info->name);

				DeviceInstance.Connection.MIDIStream = MIDIStream;

				LoadDeviceData( DeviceInstance.Data.DeviceName, DeviceInstance.Data );

				InputConnections.Add( i, DeviceInstance );
			}
		}
	}
}
コード例 #5
0
ファイル: hdumpdev.c プロジェクト: GregorR/humidity
int main(int argc, char **argv)
{
    int argi, i;
    char *arg, *nextarg;
    PmError perr;
    PtError pterr;

    PmDeviceID dev = -1;
    int list = 0;

    for (argi = 1; argi < argc; argi++) {
        arg = argv[argi];
        nextarg = argv[argi+1];
        if (arg[0] == '-') {
            if (!strcmp(arg, "-l")) {
                list = 1;
            } else if (!strcmp(arg, "-i") && nextarg) {
                dev = atoi(nextarg);
                argi++;
            } else {
                fprintf(stderr, "Invalid invocation.\n");
                exit(1);
            }
        }
    }

    PSF(perr, Pm_Initialize, ());
    PTSF(pterr, Pt_Start, (1, dump, NULL));

    /* list devices */
    if (list) {
        int ct = Pm_CountDevices();
        PmDeviceID def = Pm_GetDefaultInputDeviceID();
        const PmDeviceInfo *devinf;

        for (i = 0; i < ct; i++) {
            devinf = Pm_GetDeviceInfo(i);
            printf("%d%s: %s%s %s\n", i, (def == i) ? "*" : "",
                (devinf->input) ? "I" : "",
                (devinf->output) ? "O" : "",
                devinf->name);
        }
    }

    /* choose device */
    if (dev == -1) {
        fprintf(stderr, "Warning: Using default device.\n");
        dev = Pm_GetDefaultInputDeviceID();
    }

    /* open it for input */
    PSF(perr, Pm_OpenInput, (&stream, dev, NULL, 1024, NULL, NULL));
    PSF(perr, Pm_SetFilter, (stream, PM_FILT_ACTIVE | PM_FILT_SYSEX));

    while (1) Pt_Sleep(1<<31);

    return 0;
}
コード例 #6
0
void NxMidiManager::GetMidiOutputList( std::vector<std::string> & MidiOutputList )
{
	 for (int i = 0; i < Pm_CountDevices(); i++)  {
        const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
		if( info->output ) {
			MidiOutputList.push_back( string( info->name ) );
		}
	 }
}
コード例 #7
0
void NxMidiManager::ListMidiOutputs()
{
	Midi_Outputs.clear();
	for (int i = 0; i < Pm_CountDevices(); i++) {
		const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
		if( info->output ) {
			Midi_Outputs.insert( make_pair( i , string(  info->name ) ) );
		}
	}
}
コード例 #8
0
std::vector<std::string> MidiSession::getDevices()
{
    auto numMidiInputs = Pm_CountDevices();
    std::vector<std::string> devices;
    for (auto input = 0; input < numMidiInputs; input++)
    {
        std::string device = Pm_GetDeviceInfo(input)->name;
        devices.emplace_back(device);
    }
    return devices;
}
コード例 #9
0
ファイル: pm.cpp プロジェクト: IsaacWeiss/MuseScore
QStringList PortMidiDriver::deviceOutList() const
      {
      QStringList ol;
      int interf = Pm_CountDevices();
      for (PmDeviceID id = 0; id < interf; id++) {
            const PmDeviceInfo* info = Pm_GetDeviceInfo((PmDeviceID)id);
            if(info->output)
                ol.append(QString(info->interf) + "," + QString(info->name));
            }
      return ol;
      }
コード例 #10
0
ファイル: pm.cpp プロジェクト: IsaacWeiss/MuseScore
int PortMidiDriver::getDeviceOut(const QString& interfaceAndName)
      {
      int interf = Pm_CountDevices();
      for (int id = 0; id < interf; id++) {
            const PmDeviceInfo* info = Pm_GetDeviceInfo((PmDeviceID)id);
            if (info->output) {
                  if (QString(info->interf) + "," + QString(info->name) == interfaceAndName)
                        return id;
                  }
            }
      return -1;
      }
コード例 #11
0
ファイル: port_midi.c プロジェクト: ssj71/reMID.lv2
int port_init_seq()
{
    //if(seq_handle!=NULL) return 1;

    pm_status=Pm_Initialize();
    if(pm_status!=pmNoError)
    {
        fprintf(stderr, "Error initialising PortMIDI\n");
        return 0;
    }

    int i;
    const PmDeviceInfo *pm_dev_info;
    int num_devices=Pm_CountDevices();
    printf("Available MIDI devices:\n");
    for(i=0; i<num_devices; i++)
    {
        pm_dev_info=Pm_GetDeviceInfo(i);
        if(pm_dev_info->input) printf("%d: %s\n", i, pm_dev_info->name);
    }
    printf("\n");

    pm_status=Pm_OpenInput(&pm_stream, midiport, DRIVER_INFO, INPUT_BUFFER_SIZE, NULL, NULL);
    if(pm_status!=pmNoError)
    {
        fprintf(stderr, "Error opening MIDI input device\n");
    }


    /*
    	if(snd_seq_open(&seq_handle, "default", SND_SEQ_OPEN_INPUT, 0)<0) {
    		fprintf(stderr, "Error opening ALSA sequencer.\n");
    		return 0;
    	}

    	snd_seq_set_client_name(seq_handle, clientname);

    	in_port=snd_seq_create_simple_port(seq_handle, portname,
    		SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE,
    		SND_SEQ_PORT_TYPE_APPLICATION);

    	if(in_port<0) {
    		fprintf(stderr, "Error creating sequencer port.\n");
    		return 0;
    	}

    	npfd=snd_seq_poll_descriptors_count(seq_handle, POLLIN);
    	pfd=(struct pollfd *)malloc(npfd*sizeof(struct pollfd));
    	snd_seq_poll_descriptors(seq_handle, pfd, npfd, POLLIN);
    */

    return 1;
}
コード例 #12
0
static Scheme_Object *list_devices(int argc, Scheme_Object **argv)
{
const PmDeviceInfo *info; // portMidi device info
Scheme_Object *output_list;

  /*
   * Use PortMidi info to build an array of device info objects
   */
  Scheme_Object *device_info[Pm_CountDevices()];

  /* device info object with details about the device:
   *  int index
   *  string direction -->  IN or OUT
   *  string name
   */
  Scheme_Object *device_info_detail[Pm_CountDevices()][3];

  // Build a list of lists
  for(int d=0;d<Pm_CountDevices();d++)
  {
    device_info_detail[d][0]=scheme_make_integer(d);
    info = Pm_GetDeviceInfo(d);

    if(info->input > 0)
      device_info_detail[d][1]=scheme_make_utf8_string("IN");
    else if(info->output > 0)
      device_info_detail[d][1]=scheme_make_utf8_string("OUT");
    else
      device_info_detail[d][1]=scheme_make_utf8_string("-");

    device_info_detail[d][2]=scheme_make_utf8_string(info->name);

    device_info[d]=scheme_build_list(3,device_info_detail[d]);
  } // for

  output_list=scheme_build_list(Pm_CountDevices(),device_info);

  return output_list;
} // list_devices()
コード例 #13
0
ファイル: pm.cpp プロジェクト: Angeldude/MuseScore
int PortMidiDriver::getDeviceIn(const QString& name)
      {
      int interf = Pm_CountDevices();
      for (int id = 0; id < interf; id++) {
            const PmDeviceInfo* info = Pm_GetDeviceInfo((PmDeviceID)id);
            if (info->input) {
                  QString n = QString(info->interf) + "," + QString(info->name);
                  if (n == name)
                        return id;
                  }
            }
      return -1;
      }
コード例 #14
0
ファイル: MidiIOPrefs.cpp プロジェクト: ruthmagnus/audacity
/// Gets the lists of names and lists of labels which are
/// used in the choice controls.
/// The names are what the user sees in the wxChoice.
/// The corresponding labels are what gets stored.
void MidiIOPrefs::GetNamesAndLabels() {
   // Gather list of hosts.  Only added hosts that have devices attached.
   int nDevices = Pm_CountDevices();
   for (int i = 0; i < nDevices; i++) {
      const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
      if (info->output || info->input) { //should always happen
         wxString name(info->interf, wxConvLocal);
         if (mHostNames.Index(name) == wxNOT_FOUND) {
            mHostNames.Add(name);
            mHostLabels.Add(name);
         }
      }
   }
}
コード例 #15
0
ファイル: portmidiutil.c プロジェクト: curiousbadger/denemo
PmDeviceID
get_portmidi_device_id (char const *name, gboolean output)
{
  PmError err = Pm_InitializeWrapper ();
  if (err != pmNoError)
    {
      return pmNoDevice;
    }

  PmDeviceID ret = pmNoDevice;

  if (g_strcmp0 (name, "default") == 0)
    {
      if (output)
        {
          ret = Pm_GetDefaultOutputDeviceID ();
          goto out;
        }
      else
        {
          ret = Pm_GetDefaultInputDeviceID ();
          goto out;
        }
    }

  int num = Pm_CountDevices ();

  int i;
  for (i = 0; i < num; ++i)
    {
      PmDeviceInfo const *info = Pm_GetDeviceInfo (i);

      char *s = g_strdup_printf ("%s: %s", info->interf, info->name);

      // check if the device type (input/output) and name matches
      if (((output && info->output) || (!output && info->input)) && g_strcmp0 (name, s) == 0)
        {
          ret = i;
          g_free (s);
          break;
        }

      g_free (s);
    }

out:
  Pm_TerminateWrapper ();

  return ret;
}
コード例 #16
0
ファイル: portmidi.c プロジェクト: crazii/mameplus
osd_midi_device *osd_open_midi_output(const char *devname)
{
    int num_devs = Pm_CountDevices();
    int found_dev = -1;
    const PmDeviceInfo *pmInfo;
    PortMidiStream *stm;
    osd_midi_device *ret;

    if (!strcmp("default", devname))
    {
        found_dev = Pm_GetDefaultOutputDeviceID();
    }
    else
    {
        for (int i = 0; i < num_devs; i++)
        {
            pmInfo = Pm_GetDeviceInfo(i);

            if (pmInfo->output)
            {
                if (!strcmp(devname, pmInfo->name))
                {
                    found_dev = i;
                    break;
                }
            }
        }
    }

    if (found_dev >= 0)
    {
        if (Pm_OpenOutput(&stm, found_dev, NULL, 100, NULL, NULL, 0) == pmNoError)
        {
            ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device));
            memset(ret, 0, sizeof(osd_midi_device));
            ret->pmStream = stm;
            return ret;
        }
        else
        {
            printf("Couldn't open PM device\n");
            return NULL;
        }
    }
    else
    {
        return NULL;
    }
    return NULL;
}
コード例 #17
0
ファイル: pmidi.c プロジェクト: hlolli/csound
static int portMidi_getRealDeviceID(int dev, int output)
{
    int           i, j, cnt;
    PmDeviceInfo  *info;

    cnt = (int)Pm_CountDevices();
    i = j = -1;
    while (++i < cnt) {
      info = (PmDeviceInfo*)Pm_GetDeviceInfo((PmDeviceID) i);
      if ((output && !(info->output)) || (!output && !(info->input)))
        continue;
      if (++j == dev)
        return i;
    }
    return -1;
}
コード例 #18
0
/// Gets the lists of names and lists of labels which are
/// used in the choice controls.
/// The names are what the user sees in the wxChoice.
/// The corresponding labels are what gets stored.
void MidiIOPrefs::GetNamesAndLabels() {
   // Gather list of hosts.  Only added hosts that have devices attached.
   Pm_Terminate(); // close and open to refresh device lists
   Pm_Initialize();
   int nDevices = Pm_CountDevices();
   for (int i = 0; i < nDevices; i++) {
      const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
      if (info->output || info->input) { //should always happen
         wxString name = wxSafeConvertMB2WX(info->interf);
         if (mHostNames.Index(name) == wxNOT_FOUND) {
            mHostNames.Add(name);
            mHostLabels.Add(name);
         }
      }
   }
}
コード例 #19
0
ファイル: pmidi.c プロジェクト: hlolli/csound
static int portMidi_getPackedDeviceID(int dev, int output)
{
    int           i, j, cnt;
    PmDeviceInfo  *info;

    cnt = (int)Pm_CountDevices();
    i = j = -1;
    while (++i < cnt) {
      info = (PmDeviceInfo*)Pm_GetDeviceInfo((PmDeviceID) i);
      if ((output && info->output) || (!output && info->input))
        j++;
      if (i == dev)
        return j;
    }
    return -1;
}
コード例 #20
0
ファイル: md_portmidi.c プロジェクト: Rotbaeckchen/pyo
PyObject *
portmidi_list_devices() {
    int i;
    printf("MIDI devices:\n");
    for (i = 0; i < Pm_CountDevices(); i++) {
        const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
        if (info->input && info->output)
            printf("%d: IN/OUT, name: %s, interface: %s\n", i, info->name, info->interf);
        else if (info->input)
            printf("%d: IN, name: %s, interface: %s\n", i, info->name, info->interf);
        else if (info->output)
            printf("%d: OUT, name: %s, interface: %s\n", i, info->name, info->interf);
    }
    printf("\n");
    Py_RETURN_NONE;
}
コード例 #21
0
ファイル: portmidi.c プロジェクト: dinkc64/mame
bool osd_midi_device_pm::open_output(const char *devname)
{
	int num_devs = Pm_CountDevices();
	int found_dev = -1;
	const PmDeviceInfo *pmInfo;
	PortMidiStream *stm;

	if (!strcmp("default", devname))
	{
		found_dev = Pm_GetDefaultOutputDeviceID();
	}
	else
	{
		for (int i = 0; i < num_devs; i++)
		{
			pmInfo = Pm_GetDeviceInfo(i);

			if (pmInfo->output)
			{
				if (!strcmp(devname, pmInfo->name))
				{
					found_dev = i;
					break;
				}
			}
		}
	}

	if (found_dev >= 0)
	{
		if (Pm_OpenOutput(&stm, found_dev, NULL, 100, NULL, NULL, 0) == pmNoError)
		{
			pmStream = stm;
			return true;
		}
		else
		{
			printf("Couldn't open PM device\n");
			return false;
		}
	}
	else
	{
		return false;
	}
	return false;
}
コード例 #22
0
ファイル: pmmidi.c プロジェクト: antervud/MAMEHub
osd_midi_device *osd_open_midi_input(const char *devname)
{
	#ifndef DISABLE_MIDI
	int num_devs = Pm_CountDevices();
	int found_dev = -1;
	const PmDeviceInfo *pmInfo;
	PortMidiStream *stm;
	osd_midi_device *ret;

	for (int i = 0; i < num_devs; i++)
	{
		pmInfo = Pm_GetDeviceInfo(i);

		if (pmInfo->input)
		{
			if (!strcmp(devname, pmInfo->name))
			{
				found_dev = i;
				break;
			}
		}
	}

	if (found_dev >= 0)
	{
		if (Pm_OpenInput(&stm, found_dev, NULL, RX_EVENT_BUF_SIZE, NULL, NULL) == pmNoError)
		{
			ret = (osd_midi_device *)osd_malloc(sizeof(osd_midi_device));
			memset(ret, 0, sizeof(osd_midi_device));
			ret->pmStream = stm;
			return ret;
		}
		else
		{
			printf("Couldn't open PM device\n");
			return NULL;
		}
	}
	else
	{
		return NULL;
	}
	#else
	return NULL;
	#endif
}
コード例 #23
0
void PortMidiSettingsPage::populateDeviceLists()
{
  int i;
  for (i = 0; i < Pm_CountDevices(); i++) {
    const PmDeviceInfo *deviceInfo = Pm_GetDeviceInfo(i);
    if (!deviceInfo) {
      continue;
    }

    if (deviceInfo->input) {
      inputDeviceList->addItem(QString::fromLocal8Bit(deviceInfo->name));
    }
    if (deviceInfo->output) {
      outputDeviceList->addItem(QString::fromLocal8Bit(deviceInfo->name));
    }
  }
}
コード例 #24
0
ファイル: midiwindow.cpp プロジェクト: XT95/VisualLiveSystem
void MidiWindow::refreshHardware()
{
    ui->hardwareComboBox->clear();
    for(int i=0; i<Pm_CountDevices(); i++)
    {
        const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
        QString item = info->name;

        if( info->input )
        {
            ui->hardwareComboBox->addItem(item);
        }
        else
        {
            ui->hardwareComboBox->addItem(" ");
        }
    }
}
コード例 #25
0
ファイル: pmidi.c プロジェクト: hlolli/csound
static int portMidi_getDeviceCount(int output)
{
    int           i, cnt1, cnt2;
    PmDeviceInfo  *info;

    cnt1 = (int)Pm_CountDevices();
    if (UNLIKELY(cnt1 < 1))
      return cnt1;      /* no devices */
    cnt2 = 0;
    for (i = 0; i < cnt1; i++) {
      info = (PmDeviceInfo*)Pm_GetDeviceInfo((PmDeviceID) i);
      if (output && info->output)
        cnt2++;
      else if (!output && info->input)
        cnt2++;
    }
    return cnt2;
}
コード例 #26
0
ファイル: midiIn.c プロジェクト: JmauLeonetti/eegsynth
mxArray *getDevices() {
  const char *fieldNames[] = {"index", "name", "input", "output"};
  int i,numDevs;
  const PmDeviceInfo* info;
  mxArray *R;
  
  numDevs = Pm_CountDevices();
  R = mxCreateStructMatrix(numDevs, 1, 4, fieldNames);
  
  for (i=0;i<numDevs;i++) {
    info = Pm_GetDeviceInfo(i);
    mxSetFieldByNumber(R, i, 0, mxCreateDoubleScalar(i+1));
    mxSetFieldByNumber(R, i, 1, mxCreateString(info->name));
    mxSetFieldByNumber(R, i, 2, mxCreateDoubleScalar(info->input));
    mxSetFieldByNumber(R, i, 3, mxCreateDoubleScalar(info->output));
  }
  return R;
}
コード例 #27
0
/*!
 @function select_midi_out
 @abstract
 @discussion
 @param
 @result
 */
void select_midi_out(PortMidiStream *outstream)
{
    int i;
    int nod;
    int midiout;
    const PmDeviceInfo *di;

    //Get number of devices
    nod=Pm_CountDevices();

    //Display only MIDI OUT devices
    printf("MIDI OUT Devices\n----------------\n");
    for(i=0; i<nod; i++)
    {
        di=Pm_GetDeviceInfo(i);
        if(di->output>0)
        {
            printf("Device ID: %d\n",i);
            printf("Intreface: %s\n     Name: %s\n",di->interf,di->name);
            printf("  Outputs: %d\n",di->output);
            //printf("   Inputs: %d\n  Outputs: %d\n",(di->input>0)?di->input:0,(di->output>0)?di->output:0);
            printf("  Opened?: %s\n\n",(di->opened)?"true":"false");
        }
    }

    do
    {
        printf("Select MIDI OUT Devide ID: ");
        scanf("%d",&midiout);

        retval = Pm_OpenOutput(&outstream, midiout,NULL,512,NULL,NULL,0);
        if(retval != pmNoError)
        {
            printf("error: %s \n\n", Pm_GetErrorText(retval));
        }
        else
        {
            printf("Selected device %d\n\n",midiout);
        }
    }
    while(retval != pmNoError); //while((midiin<0|midiin>nod-1)|(di->input==0));

}
コード例 #28
0
ファイル: server.cpp プロジェクト: 2bt/terminal-tracker
void Server::start() {
	// midi
	Pm_Initialize();
	int dev_count = Pm_CountDevices();
	int i;
	for (i = 0; i < dev_count; i++) {
		auto info = Pm_GetDeviceInfo(i);
		if (info->output &&
			std::string(info->name).find("MIDI") != std::string::npos) break;
	}
	if (i < dev_count) Pm_OpenInput(&m_midi, 3, nullptr, 0, nullptr, nullptr);

	// start sound server
	static SDL_AudioSpec spec = { MIXRATE, AUDIO_S16SYS,
		2, 0, 1024, 0, 0, &Server::audio_callback, this
	};
	SDL_OpenAudio(&spec, &spec);
	SDL_PauseAudio(0);
}
コード例 #29
0
ファイル: SC_PortMIDI.cpp プロジェクト: 2mc/supercollider
int initMIDI()
{
	try {
		midiCleanUp();

		TPmErr(Pm_Initialize());
		int nbDev = Pm_CountDevices();
		int inIndex = 0;
		int outIndex = 0;
		int pmdid;

		for( int i = 0; i < nbDev ; ++i ) {
			const PmDeviceInfo* devInfo = Pm_GetDeviceInfo(i);
			if( devInfo->input )
			{
				gNumMIDIInPorts++;
				gMidiInputIndexToPmDevIndex[inIndex++] = i;
				gMidiPmDevIndexToInputIndex[i] = inIndex;
			}
			if( devInfo->output )
			{
				gNumMIDIOutPorts++;
				gMidiOutputIndexToPmDevIndex[outIndex++] = i;
				gMidiPmDevIndexToOutputIndex[i] = outIndex;
			}
		}

		for( int i = 0; i < gNumMIDIOutPorts; i++) {
			pmdid = gMidiOutputIndexToPmDevIndex[i];
			Pm_OpenOutput(&gMIDIOutStreams[i], pmdid, NULL, 512, NULL, NULL, 0);
		}

		/* will call our function, PMProcessMidi() every millisecond */
		Pt_Start(1, &PMProcessMidi, 0); /* start a timer with millisecond accuracy */
	}
	catch(PmError) {
		return errFailed;
	}

	gMIDIInitialized = true;
	return errNone;
}
コード例 #30
0
ファイル: pm.cpp プロジェクト: IsaacWeiss/MuseScore
bool PortMidiDriver::isSameCoreMidiIacBus(const QString& inInterfaceAndName, const QString& outInterfaceAndName)
      {
      int interf = Pm_CountDevices();
      const PmDeviceInfo* inInfo = 0;
      const PmDeviceInfo* outInfo = 0;
      for (PmDeviceID id = 0; id < interf; id++) {
            const PmDeviceInfo* info = Pm_GetDeviceInfo((PmDeviceID)id);
            if (info->input && inInterfaceAndName.contains(info->name))
                  inInfo = info;
            if (info->output && outInterfaceAndName.contains(info->name))
                  outInfo = info;
            }

      if (inInfo && outInfo &&
          QString(inInfo->interf) == "CoreMIDI" && QString(outInfo->interf) == "CoreMIDI" &&
          inInterfaceAndName.contains("IAC") && outInterfaceAndName == inInterfaceAndName)
            return true;
      else
            return false;
      }