size_t Alsa::getPortCount() { snd_seq_port_info_t *pinfo; snd_seq_port_info_alloca( &pinfo ); return portInfo(_apiData->seq, pinfo, SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE, -1 ); }
void Alsa::openPort(unsigned int portNumber_) { if ( _connected ) { this->closePort(); } unsigned int nSrc = this->getPortCount(); if (nSrc < 1) { std::cerr << "error: CxxMidi::Output::Alsa::openPort: no MIDI output sources found" << std::endl; } snd_seq_port_info_t *pinfo; snd_seq_port_info_alloca( &pinfo ); std::ostringstream ost; if ( portInfo( _apiData->seq, pinfo, SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE, (int) portNumber_ ) == 0 ) { std::cerr << "error: CxxMidi::Output::Alsa::openPort: port " << portNumber_ << " is invalid" << std::endl; } snd_seq_addr_t sender, receiver; receiver.client = snd_seq_port_info_get_client( pinfo ); receiver.port = snd_seq_port_info_get_port( pinfo ); sender.client = snd_seq_client_id( _apiData->seq ); if ( _apiData->vport < 0 ) { _apiData->vport = snd_seq_create_simple_port( _apiData->seq, "CxxMidi (RtMidi) output", SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ, SND_SEQ_PORT_TYPE_MIDI_GENERIC|SND_SEQ_PORT_TYPE_APPLICATION ); if ( _apiData->vport < 0 ) { std::cerr << "error: CxxMidi::Output::Alsa::openPort: error creating output port" << std::endl; } } sender.port = _apiData->vport; // Make subscription snd_seq_port_subscribe_malloc( &_apiData->subscription ); snd_seq_port_subscribe_set_sender(_apiData->subscription, &sender); snd_seq_port_subscribe_set_dest(_apiData->subscription, &receiver); snd_seq_port_subscribe_set_time_update(_apiData->subscription, 1); snd_seq_port_subscribe_set_time_real(_apiData->subscription, 1); if ( snd_seq_subscribe_port(_apiData->seq, _apiData->subscription) ) { std::cerr << "error: CxxMidi::Output::Alsa::openPort: error making port connection" << std::endl; } _connected = true; }
std::string Alsa::getPortName(unsigned int portNumber_ ) { snd_seq_client_info_t *cinfo; snd_seq_port_info_t *pinfo; snd_seq_client_info_alloca( &cinfo ); snd_seq_port_info_alloca( &pinfo ); std::string stringName; if ( portInfo( _apiData->seq, pinfo, SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE, (int) portNumber_ ) ) { int cnum = snd_seq_port_info_get_client(pinfo); snd_seq_get_any_client_info( _apiData->seq, cnum, cinfo ); std::ostringstream os; os << snd_seq_client_info_get_name(cinfo); os << ":"; os << snd_seq_port_info_get_port(pinfo); stringName = os.str(); return stringName; } std::cerr << "error: CxxMidi::Output::Alsa::getPortName: error looking for port name" << std::endl; return stringName; }
void IMU::Initiate() { XsPortInfoArray portInfoArray; xsEnumerateUsbDevices(portInfoArray); if (!portInfoArray.size()) { #ifdef PLATFORM_IS_WINDOWS throw std::runtime_error("IMU: failed to find IMU sensor"); #endif #ifdef PLATFORM_IS_LINUX XsPortInfo portInfo(pDevice->port, XsBaud::numericToRate(pDevice->baudRate)); portInfoArray.push_back(portInfo); #endif } pDevice->mtPort = portInfoArray.at(0); // Open the port with the detected device if (!pDevice->openPort(pDevice->mtPort)) throw std::runtime_error("IMU: could not open port."); Aris::Core::Sleep(10); // Put the device in configuration mode if (!pDevice->gotoConfig()) // Put the device into configuration mode before configuring the device { throw std::runtime_error("IMU: could not put device into configuration mode"); } // Request the device Id to check the device type pDevice->mtPort.setDeviceId(pDevice->getDeviceId()); // Check if we have an MTi / MTx / MTmk4 device if (!pDevice->mtPort.deviceId().isMtMk4()) { throw std::runtime_error("IMU: No MTi / MTx / MTmk4 device found."); } // Check device type if (pDevice->mtPort.deviceId().isMtMk4()) { XsOutputConfiguration config0(XDI_Quaternion, pDevice->sampleRate); XsOutputConfiguration config1(XDI_DeltaQ, pDevice->sampleRate); XsOutputConfiguration config2(XDI_DeltaV, pDevice->sampleRate); XsOutputConfiguration config3(XDI_Acceleration, pDevice->sampleRate); XsOutputConfigurationArray configArray; configArray.push_back(config0); configArray.push_back(config1); configArray.push_back(config2); configArray.push_back(config3); if (!pDevice->setOutputConfiguration(configArray)) { throw std::runtime_error("IMU: Could not configure MTmk4 pDevice-> Aborting."); } } else { throw std::runtime_error("IMU: Unknown device while configuring. Aborting."); } // Put the device in measurement mode if (!pDevice->gotoMeasurement()) { throw std::runtime_error("IMU: Could not put device into measurement mode. Aborting."); } }
SL_ext_atten << "0.0" << "3.0"; ui->CB_int2Atten->addItems(SL_ext_atten); SL_ext_atten.clear(); SL_ext_atten << "0.0" << "3.0" << "6.0" << "9.0"; ui->CB_int1Atten->addItems(SL_ext_atten); QRegExp fRegex ("^[1]{0,1}[0-9]{4,4}[.]{1,1}[0-9]{0,6}$"); QRegExpValidator *fValidator = new QRegExpValidator(fRegex, this); ui->LE_freq->setValidator(fValidator); connect(ui->PB_start,SIGNAL(clicked()),this,SLOT(portStart())); connect(ui->PB_stop,SIGNAL(clicked()),this,SLOT(protStop())); connect(ui->PB_refresh,SIGNAL(clicked()),this,SLOT(protRefresh())); connect(ui->PB_freq, SIGNAL(clicked()), this, SLOT(send_freq())); connect(protocol_inst, SIGNAL(portInfo(QString)), this, SLOT(setInfo(QString))); connect(protocol_inst, SIGNAL(portError(QString)), this, SLOT(setError(QString))); } Generator::~Generator() { delete ui; } void Generator::portStart(void) { if(protocol_inst->start(ui->CB_comList->currentText(),ui->CB_baudList->currentText().toUInt())) { setInfo("Device started."); } else