Skip to content

Instantly share code, notes, and snippets.

@lmccart
Created June 30, 2016 03:08
Show Gist options
  • Save lmccart/7489fe19189c857d61d90d1ad4d4302f to your computer and use it in GitHub Desktop.
Save lmccart/7489fe19189c857d61d90d1ad4d4302f to your computer and use it in GitHub Desktop.
#include "ofApp.h"
#include "RtAudio.h"
//--------------------------------------------------------------
void ofApp::setup() {
//causes null ptr later on during an audio call back
//for (int i = 0; i < soundDevices.size(); i++)
//{
// ofLog() << "FOUND " << soundDevices[i].deviceID << soundDevices[i].name;
// MicrophoneInput micInput;
// micInput.setup(soundDevices[i].deviceID);
// microphones.push_back(micInput);
//}
microphones = vector<MicrophoneInput>(4);
vector<ofSoundDevice> devices = soundStream.getDeviceList();
for (int i = 0; i < devices.size(); i++) {
ofLog() << "FOUND " << devices[i].name << " " << devices[i].inputChannels;
if (devices[i].inputChannels > 0) { // mics only
MicrophoneInput micInput;
micInput.setup(devices[i].deviceID);
microphones.push_back(micInput);
}
}
ofLog() << "ADDED " << microphones.size() << " DEVICES";
//Alternatively don't loop and just create one. No null ptr but still not audio call back
/*
MicrophoneInput micInput;
micInput.setup(0);
*/
}
//vector<ofSoundDevice> ofApp::getDeviceList() {
// vector<ofSoundDevice> deviceList;
// RtAudio audio;
// int n = audio.getDeviceCount();
// for (int i = 0; i < n; i++) {
// RtAudio::DeviceInfo info = audio.getDeviceInfo(i);
// ofSoundDevice device;
// device.name = info.name;
// device.outputChannels = info.outputChannels;
// device.inputChannels = info.inputChannels;
// device.sampleRates = info.sampleRates;
// deviceList.push_back(device);
// }
// return deviceList;
//}
//--------------------------------------------------------------
void ofApp::update() {
//for (int i = 0; i < microphones.size(); i++) {
// ofLog() << "update " << i;
// microphones[i].update();
// ofLog() << "volume for mic " << i << ": " << microphones[i].getVolume();
//}
}
//--------------------------------------------------------------
void ofApp::draw() {
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key) {
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key) {
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y) {
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button) {
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button) {
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button) {
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h) {
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg) {
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment