//-------------------------------------------------------------- void testApp::keyPressed (int key){ if (key == OF_KEY_UP) aubioOnsetDetect->amplitudeNumber *= 2; if (key == OF_KEY_DOWN && aubioOnsetDetect->amplitudeNumber > 3) aubioOnsetDetect->amplitudeNumber /= 2; if( key == 's' ){ inputSoundStream.start(); setupFinished = true; } if( key == 'w' ){ screenToDraw = 1 - screenToDraw; } if( key == 'e' ){ inputSoundStream.stop(); setupFinished = false;//stops it making "frozen" audio glitch sound and writes 0.0 to output sound buffer } if (key == '-'){ volume -= 0.05; volume = MAX(volume, 0); } else if (key == '+'){ volume += 0.05; volume = MIN(volume, 1); } if (key == 'u'){ setupFinished = false; inputSoundStream.close(); inputDeviceID = 0; setInputDevice(inputDeviceID); setupFinished = true; } if (key == 'j'){ setupFinished = false; inputSoundStream.close(); inputDeviceID = 1; setInputDevice(inputDeviceID); setupFinished = true; } if (key == 'p') clickSound.play(); if (key == 'i') outputIsSameAsInput = !outputIsSameAsInput; }
HidController::HidController(const hid_device_info deviceInfo) : m_pHidDevice(NULL) { // Copy required variables from deviceInfo, which will be freed after // this class is initialized by caller. hid_vendor_id = deviceInfo.vendor_id; hid_product_id = deviceInfo.product_id; hid_interface_number = deviceInfo.interface_number; if (hid_interface_number == -1) { // OS/X and windows don't use interface numbers, but usage_page/usage hid_usage_page = deviceInfo.usage_page; hid_usage = deviceInfo.usage; } else { // Linux hidapi does not set value for usage_page or usage and uses // interface number to identify subdevices hid_usage_page = 0; hid_usage = 0; } // Don't trust path to be null terminated. hid_path = new char[PATH_MAX + 1]; strncpy(hid_path, deviceInfo.path, PATH_MAX); hid_path[PATH_MAX] = 0; hid_serial_raw = NULL; if (deviceInfo.serial_number != NULL) { size_t serial_max_length = 512; hid_serial_raw = new wchar_t[serial_max_length+1]; wcsncpy(hid_serial_raw, deviceInfo.serial_number, serial_max_length); hid_serial_raw[serial_max_length] = 0; } hid_serial = safeDecodeWideString(deviceInfo.serial_number, 512); hid_manufacturer = safeDecodeWideString(deviceInfo.manufacturer_string, 512); hid_product = safeDecodeWideString(deviceInfo.product_string, 512); guessDeviceCategory(); // Set the Unique Identifier to the serial_number m_sUID = hid_serial; //Note: We include the last 4 digits of the serial number and the // interface number to allow the user (and Mixxx!) to keep track of // which is which if (hid_interface_number < 0) { setDeviceName( QString("%1 %2").arg(hid_product) .arg(hid_serial.right(4))); } else { setDeviceName( QString("%1 %2_%3").arg(hid_product) .arg(hid_serial.right(4)) .arg(QString::number(hid_interface_number))); m_sUID.append(QString::number(hid_interface_number)); } // All HID devices are full-duplex setInputDevice(true); setOutputDevice(true); m_pReader = NULL; }
void MIDIDeviceParameter::midiDeviceInAdded(MIDIInputDevice * i) { DBG("Device In added " << i->name << " / " << ghostDeviceIn); if (inputDevice == nullptr && i->name == ghostDeviceIn) { setInputDevice(i); } }
Prefs::Prefs(QObject *parent, const char *name) : QObject(parent) { this->setObjectName(name); setInputDevice(0); setOutputDevice(0); setRingDevice(0); setFilterFlag(IAXC_FILTER_AAGC|IAXC_FILTER_ECHO|IAXC_FILTER_DENOISE|IAXC_FILTER_CN); silenceThreshold = -99; // default }
void MIDIDeviceParameter::midiDeviceInRemoved(MIDIInputDevice * i) { if (i == inputDevice) { if (i != nullptr) { ghostDeviceIn = i->name; } setInputDevice(nullptr); } }
void MIDIDeviceParameter::loadJSONDataInternal(var data) { Parameter::loadJSONDataInternal(data); setInputDevice(MIDIManager::getInstance()->getInputDeviceWithName(value[0])); if (inputDevice == nullptr) ghostDeviceIn = data.getProperty("value", var())[0]; setOutputDevice(MIDIManager::getInstance()->getOutputDeviceWithName(value[1])); if (outputDevice == nullptr) ghostDeviceOut = data.getProperty("value", var())[1]; }
void testApp::checkPressOnDeviceList(int x, int y){ if (mouseX > ofGetWidth() - 360){ //check height float deviceNumber = y - deviceListHeightOffset/2; deviceNumber /= deviceListHeightDistance; int deviceInt = (int) round( deviceNumber)-1; if (showingInputDevices && inputSoundStream.deviceList[deviceInt].maxNumberOfInputs > 0){ setInputDevice(deviceInt); showingInputDevices = false; } if (showingOutputDevices && outputSoundStream.deviceList[deviceInt].maxNumberOfOutputs > 0){ setOutputDevice(deviceInt); showingOutputDevices = false; } } }
BulkController::BulkController(libusb_context* context, libusb_device_handle *handle, struct libusb_device_descriptor *desc) : m_context(context), m_phandle(handle), in_epaddr(0), out_epaddr(0) { vendor_id = desc->idVendor; product_id = desc->idProduct; manufacturer = get_string(handle, desc->iManufacturer); product = get_string(handle, desc->iProduct); m_sUID = get_string(handle, desc->iSerialNumber); setDeviceCategory(tr("USB Controller")); setDeviceName(QString("%1 %2").arg(product).arg(m_sUID)); setInputDevice(true); setOutputDevice(true); m_pReader = NULL; }
//-------------------------------------------------------------- void testApp::setup(){ /* soundStream.setup(this, 0, 2, 44100, bufferSize, 4); */ screenToDraw = 1; aubioOnsetDetect = new ofxAubioOnsetDetection(); sampleIndex = 0; outputIsSameAsInput = true; infoString = "this shows two sound streams being used\npress 's' to unpause the audio\n'e' to pause the audio\n"; infoString += "'i' to switch from using input and using sine wave for output stream"; volHistory.assign(400, 0.0); bufferCounter = 0; drawCounter = 0; smoothedVol = 0.0; scaledVol = 0.0; setupFinished = false; ofBackground(255,255,255); bufferSize = 512;//important for the beat tracker analysis - this could be improved. leftAudioIn.assign(bufferSize, 0.0); rightAudioIn.assign(bufferSize, 0.0); leftAudioOut.assign(bufferSize, 0.0); rightAudioOut.assign(bufferSize, 0.0); //setting up input and output streams // inputSoundStream.listDevices(); usePortaudioClass = true; //ofxSoundStream - class version cout << "Input process setting up input with instance of ofxPortaudioSoundstream ..." << endl; inputDeviceID = 1;//the mic(0)/line input(1) of a mac book pro outputDeviceID = 2;//the headphones out of a macbook pro setInputDevice(inputDeviceID);//includes calling the setup routine etc ofAddListener(inputSoundStream.audioReceivedEvent, this, &testApp::audioInputListener); cout << "Output process, setting up output with instance of ofxPortaudioSoundstream ..." << endl; setOutputDevice(outputDeviceID); ofAddListener(outputSoundStream.audioRequestedEvent, this, &testApp::audioOutputListener); bufferCounter = 0; ofSetFrameRate(40); //loading audio file for click sound const char *clickfilename = "cow2.wav"; clickSound.loadSound(clickfilename); clickSound.setVolume(0.1); verdana30.loadFont("verdana.ttf", 30, true, true); verdana30.setLineHeight(34.0f); verdana30.setLetterSpacing(1.035); verdana14.loadFont("verdana.ttf", 14, true, true); verdana14.setLineHeight(14.0f); verdana14.setLetterSpacing(1.035); setupFinished = true; showingInputDevices = false; showingOutputDevices = false; deviceListHeightDistance = 30; deviceListHeightOffset = 20; }