Skip to content

Commit

Permalink
visualiser updates
Browse files Browse the repository at this point in the history
  • Loading branch information
danbz committed Apr 13, 2021
1 parent 98d356a commit 5a38878
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 15 deletions.
5 changes: 3 additions & 2 deletions openFrameworks/music for homemade airports/bin/data/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generative Systems
Generative Systems for Art and Design course materials
# art and code
youube.com/danbuzzo
Generative Systems for Art and Design


Eno-esque 'Music for Airports' loop sound samples created by
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion openFrameworks/music for homemade airports/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//========================================================================
int main( ){
ofSetupOpenGL(600,400,OF_WINDOW); // <-------- setup the GL context
ofSetupOpenGL(1200,800,OF_WINDOW); // <-------- setup the GL context

// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
Expand Down
68 changes: 57 additions & 11 deletions openFrameworks/music for homemade airports/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ void ofApp::setup(){
tempo = 5000; // starting with five seconds tempo
b_autoPlay = false;
currTime = ofGetSystemTimeMillis();

ofSetBackgroundColor(0);
// ofSetBackgroundAuto(false);
b_Gui = true;

drums.load("Dirty-electronic-samples/sample13.aif");
drums.setLoop(true);
drums.play();
}

//--------------------------------------------------------------
Expand All @@ -31,6 +39,10 @@ void ofApp::update(){

//--------------------------------------------------------------
void ofApp::draw(){
// ofSetColor(0, 0, 0, 10);
// ofDrawRectangle(0, 0, ofGetWidth(), ofGetHeight());
//
ofSetColor(255);
if (b_autoPlay){ // choose a voice to play
if (ofGetSystemTimeMillis() > currTime + tempo){
int num = ofRandom(totalVoices);
Expand All @@ -40,19 +52,42 @@ void ofApp::draw(){
}
}

// onscreen display of voices that are playing
for (int i = 0; i < totalVoices; i++){
if ( voices[i].isPlaying() ){
ofDrawRectangle(90, ((i)*20) + 7 , ofMap( voices[i].getPosition(), 0, 1, 20 , (ofGetWidth() -110) ), 18 ); // draw a while progress bar
ofDrawBitmapStringHighlight( "voice " + ofToString( i +1 ) + ": ", 10, (i + 1) * 20 );
} else {
ofDrawBitmapString( "voice " + ofToString( i +1 ) + ": ", 10, (i + 1) * 20 );
if (b_Gui){
// onscreen display of voices that are playing
for (int i = 0; i < totalVoices; i++){
if ( voices[i].isPlaying() ){
ofDrawRectangle(90, ((i)*20) + 7 , ofMap( voices[i].getPosition(), 0, 1, 20 , (ofGetWidth() -110) ), 18 ); // draw a while progress bar
ofDrawBitmapStringHighlight( "voice " + ofToString( i +1 ) + ": ", 10, (i + 1) * 20 );
} else {
ofDrawBitmapString( "voice " + ofToString( i +1 ) + ": ", 10, (i + 1) * 20 );
}
}
// on screen instructions
ofDrawBitmapString("auto play is " + ofToString( b_autoPlay ) , 10, 200);
ofDrawBitmapString("tempo is " + ofToString( tempo ) + " ms" , 10, 220);
ofDrawBitmapString("press keys 1-7 to play voices \na to autoplay \n+ /- to increase/decrease tempo \n'p' to load Piano Samples \n'v' to load vocal samples", 10, 240);
}
// we make our FFT audio visualisation here
// int barWidth = 40;
ofColor drawColor;
// int length = ofGetWidth()/ 2;
int length = 10000;
int barWidth = 80;
float bandsToGet = 512;
float width = (float)(5*128) / bandsToGet;
float * val = ofSoundGetSpectrum(bandsToGet);
for (int i= 0; i < bandsToGet; i ++){
ofPushMatrix();
ofTranslate(ofGetWidth()/2 , ofGetHeight() /2);
ofRotateDeg( 360.0 / bandsToGet * i );

// ofDrawRectangle(100+i*width,ofGetHeight()-100,width,-(val[i] * 200));
//
drawColor.setHsb(255/bandsToGet* i, 255 , 255, 50);
ofSetColor(drawColor);
ofDrawRectangle(100,-barWidth/2, val[i] * length, barWidth/2);
ofPopMatrix();
}
// on screen instructions
ofDrawBitmapString("auto play is " + ofToString( b_autoPlay ) , 10, 200);
ofDrawBitmapString("tempo is " + ofToString( tempo ) + " ms" , 10, 220);
ofDrawBitmapString("press keys 1-7 to play voices \na to autoplay \n+ /- to increase/decrease tempo \n'p' to load Piano Samples \n'v' to load vocal samples", 10, 240);
}

//--------------------------------------------------------------
Expand Down Expand Up @@ -110,6 +145,15 @@ void ofApp::keyPressed(int key){
loadPiano();
break;


case 'f':
ofToggleFullscreen();
break;

case 'g':
b_Gui =!b_Gui;
break;

default:
break;
}
Expand All @@ -119,6 +163,7 @@ void ofApp::keyPressed(int key){
void ofApp::keyReleased(int key){

}
//--------------------------------------------------------------

void ofApp::loadVocal(){
// load vocal samples
Expand All @@ -133,6 +178,7 @@ void ofApp::loadVocal(){
voices.push_back(voice);
}
}
//--------------------------------------------------------------

void ofApp::loadPiano(){
// load piano samples
Expand Down
4 changes: 3 additions & 1 deletion openFrameworks/music for homemade airports/src/ofApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ class ofApp : public ofBaseApp{
bool b_autoPlay;
float tempo, currTime;
int totalVoices;

bool b_Gui;
ofSoundPlayer drums;

};

0 comments on commit 5a38878

Please sign in to comment.