Exemplo n.º 1
0
//--------------------------------------------------------------
void ofApp::keyPressed(int key)
{
    int headersSize = spreadsheet.getHeaders().size();
    for (int i = 0; i < headersSize; i++) {
        if (key == ofToChar(ofToString(i))) {
            spreadsheet.sortByCol(i,reverse);
        }
    }
    if (key == 'r') {
        reverse = !reverse;
    }
}
Boolean systemVolume::readMute() {
    
    // check to see if the system is muted 10 times per second
    // note: significantly reduces speed of system.
    // question: how do we run this in a different thread?
    
    refTime = floor(ofGetElapsedTimeMillis() % 1000);
    
    // if it's been 100 ms, update the system state
    if (refTime != prevRefTime) {
        
        string argument;
        
        argument = ofToString(ofSystem("osascript -e 'output muted of (get volume settings)'"));
        
        char muteChar = ofToChar(argument);
        
        if (muteChar == 't') muteState = true;
        if (muteChar == 'f') muteState = false;
    }
    
//    cout << ofToString(prevRefTime) + "  " + ofToString(refTime) << endl;
    
    // updated muted and unmuted flags:
    
    // transition from muted to not muted indicates start of recording
    if (!muteState && prevMuteState) {
        bUnmuted = true;
    }
    
    // transition to muted signals end of recording
    else if (muteState && !prevMuteState) {
        bMuted = true;
    }
    
    // set previous mute state
    prevMuteState = muteState;
    
    // set previous time
    prevRefTime = refTime;
    
    return muteState;
}
Exemplo n.º 3
0
//--------------------------------------------------------------
void ofApp::update(){
    //ofxFFT
    fft.setThreshold(audioThreshold);
    fft.setPeakDecay(audioPeakDecay);
    fft.setMaxDecay(audioMaxDecay);
    fft.update();
    int num = 22000;
    float * audioData = new float[num];
    fft.getFftPeakData(audioData, num);
    for (int i = 0; i < num; i++) float audioValue = audioData[i];
    audioLevel01 = audioData[targetFreq01];
    //    while (audioLevel01 > dbMax) audioLevel01 = 1.0;
    delete[] audioData;
    
    ///OSC
    while (receiver.hasWaitingMessages()) {
        ofxOscMessage message;
        receiver.getNextMessage(&message);
        value = message.getArgAsFloat(0);
        items = ofSplitString(message.getAddress(), "/");
        address = ofToChar(items.back());
        cout << address << '\n';
        switch (address) {
            case 'a' : a01 = value; break;
            case 'b' : a02 = value; break;
            case 'c' : a03 = value; break;
            case 'd' : a04 = value; break;
            case 'e' : a05 = value; break;
            case 'f' : a06 = value; break;
            case 'g' : a07 = value; break;
            case 'h' : a08 = value; break;
            case 'i' : a09 = value; break;
            case 'j' : a10 = value; break;
            case 'k' : b01 = value; break;
            case 'l' : b02 = value; break;
            case 'm' : b03 = value; break;
            case 'n' : b04 = value; break;
            case 'o' : b05 = value; break;
            case 'p' : b06 = value; break;
            case 'q' : b07 = value; break;
            case 'r' : b08 = value; break;
            case 's' : b09 = value; break;
            case 't' : b10 = value; break;
            case 'u' : c01 = value; break;
            case 'v' : c02 = value; break;
            case 'w' : c03 = value; break;
            case 'x' : c04 = value; break;
            case 'y' : c05 = value; break;
            case 'z' : c06 = value; break;
            case '[' : c07 = value; break;
            case ']' : c08 = value; break;
            case '_' : c09 = value; break;
            case '^' : c10 = value; break;
            case '1' : visual = 1; break;
            case '2' : visual = 2; break;
            case '3' : visual = 3; break;
            case '4' : visual = 4; break;
            case '5' : visual = 5; break;
            case '6' : visual = 6; break;
            case '7' : visual = 7; break;
            case '8' : visual = 8; break;
        }
    }
    switch (visual) {
        case 1: v01_->update(); v03_->update(); v04_->update(); v05_->update(); /*v06_->update();*/ break;
        case 2: v01_->update(); v03_->update(); v04_->update(); v05_->update(); /*v06_->update();*/ break;
        case 3: v03_->update(); break;
        case 4: v04_->update(); break;
        case 5: v05_->update(); break;
        case 6: v06_->update(); break;
        case 7: v07_->update(); break;
        case 8: v08_->update(); break;
        default:
            break;
    }
}
Exemplo n.º 4
0
void testApp::setup() {
	string splitInput = " a,,b,c,";
	splitTest(" a,,b, c , ", ",");
	splitTest(" a<><>b<> c <> ", "<>");
	 
	 cout << "empty" << endl;
	 cout << ofToInt("") << endl;
	 cout << ofToFloat("") << endl;
	 cout << ofToBool("") << endl;
	 cout << ofToChar("") << endl;
	 cout << endl;
	 
	 cout << "strings" << endl;
	 cout << ofToString(123) << endl;
	 cout << ofToString(123.4) << endl;
	 cout << ofToString(123.4f) << endl;
	 cout << ofToString(123, 5) << endl;
	 cout << ofToString(123.4, 5) << endl;
	 cout << ofToString(123.4f, 5) << endl;
	 cout << endl;
	 
	 cout << "ints" << endl;
	 cout << ofToInt("123.") << endl;
	 cout << ofToInt("123.4") << endl;
	 cout << ofToInt("123.4f") << endl;
	 cout << ofToInt("+123.4") << endl;
	 cout << endl;
	 
	 cout << "float" << endl;
	 cout << ofToFloat("123.") << endl;
	 cout << ofToFloat("123.4") << endl;
	 cout << ofToFloat("123.4f") << endl;
	 cout << ofToFloat("+123.4") << endl;
	 cout << endl;
	 
	 cout << "bool" << endl;
	 cout << ofToBool("1") << endl;
	 cout << ofToBool("0") << endl;
	 cout << ofToBool("true") << endl;
	 cout << ofToBool("false") << endl;
	 cout << ofToBool("True") << endl;
	 cout << ofToBool("False") << endl;
	 cout << endl;
	 
	 cout << "char" << endl;
	 cout << ofToChar("a") << endl;
	 cout << ofToChar("b") << endl;
	 cout << ofToChar("1") << endl;
	 cout << ofToChar("0") << endl;
	 cout << endl;	
	 
	 cout << "to binary" << endl;
	 cout << ofToBinary(8) << endl;
	 cout << ofToBinary(64) << endl;
	 cout << ofToBinary(1024) << endl;
	 cout << ofToBinary('a') << endl;
	 cout << ofToBinary(8.5) << endl;
	 cout << ofToBinary(8.f) << endl;
	 cout << ofToBinary(8.5f) << endl;
	 cout << ofToBinary(9.f) << endl;
	 string strVal = "abc";
	 cout << ofToBinary(strVal) << endl;
	 cout << ofToBinary("abc") << endl;
	 cout << endl;
	 
	 cout << "to binary" << endl;
	 cout << ofBinaryToInt(ofToBinary(8)) << endl;
	 cout << ofBinaryToInt(ofToBinary(64)) << endl;
	 cout << ofBinaryToInt(ofToBinary(1024)) << endl;
	 cout << ofBinaryToChar(ofToBinary('a')) << endl;
	 cout << ofBinaryToFloat(ofToBinary(8.5f)) << endl;
	 cout << ofBinaryToFloat(ofToBinary(64.5f)) << endl;
	 cout << ofBinaryToString(ofToBinary("abc")) << endl;
	 cout << endl;
	 
	 cout << "to hex" << endl;
	 cout << ofToHex('a') << endl;
	 cout << ofToHex(128) << endl;
	 cout << ofToHex(128.f) << endl;
	 cout << ofToHex(128.) << endl;
	 cout << ofToHex("abc") << endl;
	 cout << ofToHex("abcd") << endl;
	 string val = "abcdefg";
	 cout << ofToHex(val) << endl;
	 cout << endl;
	 
	 cout << "hex to int" << endl;
	 cout << ofHexToInt("0xff") << endl;
	 cout << ofHexToInt("ff") << endl;
	 cout << ofHexToInt(ofToHex(128)) << endl;
	 cout << ofHexToFloat(ofToHex(128.5f)) << endl;
	 cout << ofHexToChar(ofToHex('a')) << endl;
	 cout << ofHexToString(ofToHex("abc")) << endl;
	 cout << endl;
}