<commit_before>//
//  Part of ofxAVUI addon. Developed by <NAME> and <NAME> in 2016.
//  https://github.com/AVUIs/ofxAVUI
//

#include "ofApp.h"


//--------------------------------------------------------------
void ofApp::setup(){
    
    //ENVIRONMENT AND MAXIMILIAN
    ofSetFrameRate(60);
    ofSetVerticalSync(true);
    ofEnableAlphaBlending();
    ofEnableSmoothing();
    ofBackground(0,0,0);
    sampleRate 	= 44100; /* Audio sampling rate */
    bufferSize	= 512; /* Audio buffer size */
    ofxMaxiSettings::setup(sampleRate, 2, bufferSize);
    
    ofColor bg(100,100,100,150);
    ofColor fg(255);
    
    //sequencing
    now = ofGetElapsedTimeMillis();
    delay = 1000;
    numSequencerSteps = 16;
    
    //UI positions and dimensions
    padBounds.x = 150;
    padBounds.y = 50;
    padBounds.width = padBounds.height = 625;
    
    sequencerX = padBounds.x+padBounds.width+25;
    sequencerY = padBounds.y;
    sequencerW = 330;
    sequencerToggleH = 100;
    sequencerStepH = 25;
    
    //parameter names
    xParamName = "x";
    yParamName = "y";
    timerParamName = "timer";
    playbackParamName = "playback";
    filterSpeedParamName = "filter speed";
    resetParamName = "reset playback gesture";
    
    //ZONE SETUP
    //parameters: name, x, y, width, background color, foreground color, sound filename, sound buffer size
    //PAD
    zonePad.setup("padZone", padBounds.x, padBounds.y, padBounds.width, bg,fg, "synth.wav", bufferSize);
    zonePad.addParameterFloat(xParamName, 0.0, 1.0, 0.5);
    zonePad.addParameterFloat(yParamName, 0.0, 1.0, 0.5);
    zonePad.addUI(new ofxAVUIXYPad("Pad", "","", xParamName,yParamName), padBounds.height);
    
    //SEQUENCER
    //kick.wav = https://www.freesound.org/people/DWSD/sounds/171104/
    zoneSequencer.setup("toggleZone", sequencerX, sequencerY, sequencerW, bg, fg, "kick.wav", bufferSize);
    //ZONE UI
    zoneSequencer.addParameterBool(playbackParamName, true);
    zoneSequencer.addUI(new ofxAVUIToggle(playbackParamName,playbackParamName), sequencerToggleH);

    sequencerTogglePrefix = "toggle #";
    for(int i = 0 ; i < numSequencerSteps; i++){
        string toggleParamName = sequencerTogglePrefix + (ofToString(i));
        zoneSequencer.addParameterBool(toggleParamName, false);
        zoneSequencer.addUI(new ofxAVUIToggle(toggleParamName,toggleParamName), sequencerStepH);
    }
    //timer control
    //params
    zoneSequencer.addParameterFloat(timerParamName, 125, 2000, delay);
    zoneSequencer.addParameterBool(resetParamName, false);
    zoneSequencer.addParameterFloat(filterSpeedParamName, 0.010, 0.100, 0.025);
    //ui
    zoneSequencer.addUI(new ofxAVUIEmpty(""), sequencerStepH);
    //slider parameters: caption, trigger (single tap) parameter name, toggle (double tap) parameter name, x parameter name
    zoneSequencer.addUI(new ofxAVUISlider(timerParamName,"","",timerParamName), sequencerStepH);
    zoneSequencer.addUI(new ofxAVUISlider(filterSpeedParamName,"","",filterSpeedParamName), sequencerStepH);
    zoneSequencer.addUI(new ofxAVUIEmpty(""), sequencerStepH);
    zoneSequencer.addUI(new ofxAVUIButton(resetParamName,resetParamName),sequencerStepH);
    //sound FX
    ofxAVUISoundFxFilter *sfx = new ofxAVUISoundFxFilter();
    //sound fx parameters:
    //- filter enabled toggle name (will be linked to any toggle UI with same name), start value
    //- 1st parameter float name (will be linked to any toggle UI with same name), min value, max value, start value
    //- 2nd parameter float name (will be linked to any toggle UI with same name), min value, max value, start value
    sfx->setup("filterToggle", true, "frequency", 200, 20000, 200, "resonance", 0, 100, 10);
    zoneSequencer.addSoundFx(sfx);
    //START SOUND
    ofSoundStreamSetup(2,2,this, sampleRate, bufferSize, 4); /* this has to happen at the end of setup*/
    
}

//--------------------------------------------------------------
void ofApp::update(){
    //sequencer timing
    int millis = ofGetElapsedTimeMillis();
    if(millis - now >= delay){
        //increment sequencer step
        currentSequencerStep = (currentSequencerStep +1 ) % numSequencerSteps;
        
        bool isOn = zoneSequencer.getParamValueBool(sequencerTogglePrefix+ofToString(currentSequencerStep));
        
        if(zoneSequencer.getParamValueBool(playbackParamName))
            zoneSequencer.getParamValueBool(ofxAVUIZone::TOGGLE_PLAY) = isOn;
        
        now = millis;
    }<commit_msg>Fixed sequencer example<commit_after>//
//  Part of ofxAVUI addon. Developed by <NAME> and <NAME> in 2016.
//  https://github.com/AVUIs/ofxAVUI
//

#include "ofApp.h"


//--------------------------------------------------------------
void ofApp::setup(){
    
    //ENVIRONMENT AND MAXIMILIAN
    ofSetFrameRate(60);
    ofSetVerticalSync(true);
    ofEnableAlphaBlending();
    ofEnableSmoothing();
    ofBackground(0,0,0);
    sampleRate 	= 44100; /* Audio sampling rate */
    bufferSize	= 512; /* Audio buffer size */
    ofxMaxiSettings::setup(sampleRate, 2, bufferSize);
    
    ofColor bg(100,100,100,150);
    ofColor fg(255);
    
    //sequencing
    now = ofGetElapsedTimeMillis();
    delay = 1000;
    numSequencerSteps = 16;
    
    //UI positions and dimensions
    padBounds.x = 150;
    padBounds.y = 50;
    padBounds.width = padBounds.height = 625;
    
    sequencerX = padBounds.x+padBounds.width+25;
    sequencerY = padBounds.y;
    sequencerW = 330;
    sequencerToggleH = 100;
    sequencerStepH = 25;
    
    //parameter names
    xParamName = "x";
    yParamName = "y";
    timerParamName = "timer";
    playbackParamName = "playback";
    filterSpeedParamName = "filter speed";
    resetParamName = "reset playback gesture";
    
    //ZONE SETUP
    //parameters: name, x, y, width, background color, foreground color, sound filename, sound buffer size
    //PAD
    zonePad.setup("padZone", padBounds.x, padBounds.y, padBounds.width, bg,fg, "synth.wav", bufferSize);
    zonePad.addParameterFloat(xParamName, 0.0, 1.0, 0.5);
    zonePad.addParameterFloat(yParamName, 0.0, 1.0, 0.5);
    zonePad.addUI(new ofxAVUIXYPad("Pad", "","", xParamName,yParamName), padBounds.height);
    
    //SEQUENCER
    //kick.wav = https://www.freesound.org/people/DWSD/sounds/171104/
    zoneSequencer.setup("toggleZone", sequencerX, sequencerY, sequencerW, bg, fg, "kick.wav", bufferSize);
    //ZONE UI
    zoneSequencer.addParameterBool(playbackParamName, true);
    zoneSequencer.addUI(new ofxAVUIToggle(playbackParamName,playbackParamName), sequencerToggleH);

    sequencerTogglePrefix = "toggle #";
    for(int i = 0 ; i < numSequencerSteps; i++){
        string toggleParamName = sequencerTogglePrefix + (ofToString(i));
        zoneSequencer.addParameterBool(toggleParamName, false);
        zoneSequencer.addUI(new ofxAVUIToggle(toggleParamName,toggleParamName), sequencerStepH);
    }
    //timer control
    //params
    zoneSequencer.addParameterFloat(timerParamName, 125, 2000, delay);
    zoneSequencer.addParameterBool(resetParamName, false);
    zoneSequencer.addParameterFloat(filterSpeedParamName, 0.010, 0.100, 0.025);
    //ui
    zoneSequencer.addUI(new ofxAVUIEmpty(""), sequencerStepH);
    //slider parameters: caption, trigger (single tap) parameter name, toggle (double tap) parameter name, x parameter name
    zoneSequencer.addUI(new ofxAVUISlider(timerParamName,"","",timerParamName), sequencerStepH);
    zoneSequencer.addUI(new ofxAVUISlider(filterSpeedParamName,"","",filterSpeedParamName), sequencerStepH);
    zoneSequencer.addUI(new ofxAVUIEmpty(""), sequencerStepH);
    zoneSequencer.addUI(new ofxAVUIButton(resetParamName,resetParamName),sequencerStepH);
    //sound FX
    ofxAVUISoundFxFilter *sfx = new ofxAVUISoundFxFilter();
    //sound fx parameters:
    //- filter enabled toggle name (will be linked to any toggle UI with same name), start value
    //- 1st parameter float name (will be linked to any toggle UI with same name), min value, max value, start value
    //- 2nd parameter float name (will be linked to any toggle UI with same name), min value, max value, start value
    sfx->setup("filterToggle", true, "frequency", 200, 20000, 200, "resonance", 0, 100, 10);
    zoneSequencer.addSoundFx(sfx);
    //START SOUND
    ofSoundStreamSetup(2,2,this, sampleRate, bufferSize, 4); /* this has to happen at the end of setup*/
    
}

//--------------------------------------------------------------
void ofApp::update(){
    //sequencer timing
    int millis = ofGetElapsedTimeMillis();
    if(millis - now >= delay){
        //increment sequencer step
        currentSequencerStep = (currentSequencerStep +1 ) % numSequencerSteps;
        
        bool isOn = zoneSequencer.getParamValueBool(sequencerTogglePrefix+ofToString(currentSequencerStep));
        
        if(zoneSequencer.getParamValueBool(playbackParamName))
            zoneSequencer.getParamValueBool(ofxAVUIZone::TRIGGER_PLAY) = isOn;
        
        now = millis;
    }
{'fraction_non_alphanumeric': 0.14115816383238858, 'fraction_numerical': 0.026230965877514726, 'mean_word_length': 3.190964136003726, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5502006', 'n_tokens_mistral': 3014, 'n_tokens_neox': 2810, 'n_words': 638}