• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Pm_GetDeviceInfo函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Pm_GetDeviceInfo函数的典型用法代码示例。如果您正苦于以下问题:C++ Pm_GetDeviceInfo函数的具体用法?C++ Pm_GetDeviceInfo怎么用?C++ Pm_GetDeviceInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Pm_GetDeviceInfo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: keyboard_init

int keyboard_init(MidiObj* m,char* name) {
		
	m->midi_stream_out = NULL;
	m->midi_stream = NULL;
	
	// open midi device
	if(! initialized)
	{
		Pm_Initialize();
		initialized=1;
	}

	int devid= find_device_id_in(name);
	int devid_out= find_device_id_out(name);
	const PmDeviceInfo* dev_info = Pm_GetDeviceInfo(devid);
	const PmDeviceInfo* dev_info_out = Pm_GetDeviceInfo(devid_out);

	if(dev_info_out) {
		Pm_OpenOutput(&(m->midi_stream_out), devid_out, NULL, KEYBOARD_MAX_EVENTS, NULL, NULL,0);
	}
	if(dev_info) {
		Pm_OpenInput(&(m->midi_stream), devid, NULL, KEYBOARD_MAX_EVENTS, NULL, NULL);
		return 1;
	}
	return 0;
}
开发者ID:glocklueng,项目名称:midiDmxCtrlv2,代码行数:26,代码来源:keyboard.c


示例2: Pm_CountDevices

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)" : "");
		}
	}
}
开发者ID:ccmurray,项目名称:mame,代码行数:35,代码来源:portmidi.cpp


示例3: Pm_CountDevices

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 );
			}
		}
	}
}
开发者ID:Codermay,项目名称:Unreal4,代码行数:25,代码来源:LiveEditorManager.cpp


示例4: Pm_GetDeviceInfo

/*
 * Method:    Pm_GetDeviceName
 */
JNIEXPORT jstring JNICALL Java_jportmidi_JPortMidiApi_Pm_1GetDeviceName
  (JNIEnv *env, jclass cl, jint i)
{
    const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
    if (!info) return NULL;
    return (*env)->NewStringUTF(env, info->name);
}
开发者ID:AkiraShirase,项目名称:audacity,代码行数:10,代码来源:pmjni.c


示例5: Pm_CountDevices

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;
        }
    }
}
开发者ID:DannyvanSwieten,项目名称:APAudioFramework,代码行数:28,代码来源:MidiInput.cpp


示例6: pm_find_default_device

/* utility to look up device, given a pattern,
   note: pattern is modified
 */
int pm_find_default_device(char *pattern, int is_input)
{
    int id = pmNoDevice;
    int i;
    /* first parse pattern into name, interf parts */
    char *interf_pref = ""; /* initially assume it is not there */
    char *name_pref = strstr(pattern, ", ");

    if (name_pref) { /* found separator, adjust the pointer */
        interf_pref = pattern;
        name_pref[0] = 0;
        name_pref += 2;
    } else {
        name_pref = pattern; /* whole string is the name pattern */
    }
    for (i = 0; i < pm_descriptor_index; i++) {
        const PmDeviceInfo *info = Pm_GetDeviceInfo(i);
        if (info->input == is_input &&
            strstr(info->name, name_pref) &&
            strstr(info->interf, interf_pref)) {
            id = i;
            break;
        }
    }
    return id;
}
开发者ID:lgblgblgb,项目名称:ep128emu,代码行数:29,代码来源:portmidi.c


示例7: midiInit

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;
}
开发者ID:amoweb,项目名称:RaspberryBoucle,代码行数:35,代码来源:midi.c


示例8: main

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;
}
开发者ID:GregorR,项目名称:humidity,代码行数:58,代码来源:hdumpdev.c


示例9: Pm_GetDeviceInfo

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 ) );
		}
	 }
}
开发者ID:nxgraphics,项目名称:NxGraphics,代码行数:9,代码来源:NxDevice_Midi_Manager.cpp


示例10: portMidi_getRealDeviceID

static PmDeviceInfo *portMidi_getDeviceInfo(int dev, int output)
{
    int i;

    i = portMidi_getRealDeviceID(dev, output);
    if (UNLIKELY(i < 0))
      return NULL;
    return ((PmDeviceInfo*)Pm_GetDeviceInfo((PmDeviceID) i));
}
开发者ID:hlolli,项目名称:csound,代码行数:9,代码来源:pmidi.c


示例11: keyboard_init

int keyboard_init() {
	Pm_Initialize();
	const PmDeviceInfo* dev_info = Pm_GetDeviceInfo(KEYBOARD_DEV_ID);
	if (dev_info) {
		Pm_OpenInput(&midi_stream, KEYBOARD_DEV_ID, NULL, KEYBOARD_MAX_EVENTS, NULL, NULL);
		return 1;
	}
	return 0;
}
开发者ID:2bt,项目名称:little-synths,代码行数:9,代码来源:keyboard.c


示例12: Pm_CountDevices

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;
      }
开发者ID:IsaacWeiss,项目名称:MuseScore,代码行数:11,代码来源:pm.cpp


示例13: port_init_seq

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;
}
开发者ID:ssj71,项目名称:reMID.lv2,代码行数:53,代码来源:port_midi.c


示例14: osd_list_midi_devices

void osd_list_midi_devices(void)
{
	#ifndef DISABLE_MIDI
	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)" : "");
		}
	}
	#else
	printf("\nMIDI is not supported in this build\n");
	#endif
}
开发者ID:antervud,项目名称:MAMEHub,代码行数:39,代码来源:pmmidi.c


示例15: Pm_CountDevices

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;
      }
开发者ID:Angeldude,项目名称:MuseScore,代码行数:13,代码来源:pm.cpp


示例16: Pm_CountDevices

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;
}
开发者ID:crazii,项目名称:mameplus,代码行数:50,代码来源:portmidi.c


示例17: Pm_CountDevices

/// 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);
         }
      }
   }
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:18,代码来源:MidiIOPrefs.cpp


示例18: get_portmidi_device_id

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;
}
开发者ID:curiousbadger,项目名称:denemo,代码行数:50,代码来源:portmidiutil.c


示例19: find_device_id_out

static int find_device_id_out(char* name)
{
	const PmDeviceInfo *di;
	for(int i= 0; ; i++)
	{
		di= Pm_GetDeviceInfo(i);
		if(!di) break;
		if(strstr(di->name, name) && di->output)
		{
			printf("found out device '%s' with interf '%s'\n", di->name, di->interf);
			return i;
		}
	}
	return -1;
}
开发者ID:glocklueng,项目名称:midiDmxCtrlv2,代码行数:15,代码来源:keyboard.c


示例20: Pm_Terminate

/// 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);
         }
      }
   }
}
开发者ID:RaphaelMarinier,项目名称:audacity,代码行数:20,代码来源:MidiIOPrefs.cpp



注:本文中的Pm_GetDeviceInfo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Pmsg1函数代码示例发布时间:2022-05-30
下一篇:
C++ PlayerNoise函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap