ofxStk icon indicating copy to clipboard operation
ofxStk copied to clipboard

Could not open or find file (rawwaves)

Open ohelli opened this issue 7 years ago • 7 comments

Hello Ahbee, i'm currently looking into your example_simple as I want to use ofxStk in my project. Upon starting, I am receiving a Fileread::open Error:

bildschirmfoto 2017-05-23 um 19 08 54

I have the files set up just as I downloaded them:

bildschirmfoto 2017-05-23 um 19 06 09

Can you tell me, if theres something missing? Thanks in advance, Elli

ohelli avatar May 23 '17 17:05 ohelli

Is this just from trying to run "example_simple"? What version of openframeworks are you on? i see some ios stuff are you trying to make it run in ios?

Ahbee avatar May 24 '17 00:05 Ahbee

if you are on ios you have to call stk::Stk::setRawwavePath(ofToDataPath("rawwaves")) before making any calls to stk. in the "example_simple" there is a member stk::BeeThree synth that uses the 'rawwaves' in its constructor. That is probably what is crashing your program. So just make any stk members a shared_ptr, like std::shared_ptr<stk::BeeThree> synth

in the setup if you do

 stk::Stk::setRawwavePath(ofToDataPath("rawwaves"));
 synth = std::make_shared<stk::BeeThree>();

it should work fine.

Ahbee avatar May 24 '17 01:05 Ahbee

i'm using version 0.9.8 release. yes, i would like to use it for ios. I added both lines you mentioned above, but it still gives me the same error. Will try it further and get back to you later. Thanks.

ohelli avatar May 24 '17 07:05 ohelli

and yes, i have this problem running the "example_simple". Could it have to do with the version of of?

ohelli avatar May 24 '17 20:05 ohelli

It works for me on ios. Can you create a new ios project with project generator while selecting ofxStk as an addon Next copy the "rawwaves" folder into "bin/data" then paste the follwing code for ofApp.h and ofApp.mm

ofApp.h:

#pragma once

#include "ofxiOS.h"
#include "ofxStk.h"

class ofApp : public ofxiOSApp {
	
    public:
        void setup();
        void update();
        void draw();
        void exit();
	
        void touchDown(ofTouchEventArgs & touch);
        void touchMoved(ofTouchEventArgs & touch);
        void touchUp(ofTouchEventArgs & touch);
        void touchDoubleTap(ofTouchEventArgs & touch);
        void touchCancelled(ofTouchEventArgs & touch);

        void lostFocus();
        void gotFocus();
        void gotMemoryWarning();
        void deviceOrientationChanged(int newOrientation);
    
    
    void audioOut(float *output,int bufferSize,int nChannnels);
    std::shared_ptr<stk::BeeThree> synth;

};



ofApp.mm

#include "ofApp.h"


const float NoteC = 65.41;

const int op4FeedbackCC = 2;
const int op3GainCC = 4;
const int LFOSpeedCC = 11;
const int LFODepthCC = 1;

//--------------------------------------------------------------
void ofApp::setup(){
    stk::Stk::setRawwavePath(ofToDataPath("rawwaves"));
    stk::Stk::setSampleRate(44100.0);
    synth = std::make_shared<stk::BeeThree>();
    ofSoundStreamSetup(2, 0);

}

//--------------------------------------------------------------
void ofApp::update(){
    synth->controlChange(op4FeedbackCC, 60);
    synth->controlChange(op3GainCC, 60);
    synth->controlChange(LFOSpeedCC, 0);
    synth->controlChange(LFODepthCC,0);

}

//--------------------------------------------------------------
void ofApp::draw(){

}

//--------------------------------------------------------------
void ofApp::exit(){

}

//--------------------------------------------------------------
void ofApp::touchDown(ofTouchEventArgs & touch){
    float amplitude = .5;
    synth->noteOn(NoteC, amplitude);
}

//--------------------------------------------------------------
void ofApp::touchMoved(ofTouchEventArgs & touch){

}

//--------------------------------------------------------------
void ofApp::touchUp(ofTouchEventArgs & touch){
    synth->noteOff(.5);
}

//--------------------------------------------------------------
void ofApp::touchDoubleTap(ofTouchEventArgs & touch){

}

//--------------------------------------------------------------
void ofApp::touchCancelled(ofTouchEventArgs & touch){
    
}

//--------------------------------------------------------------
void ofApp::lostFocus(){

}

//--------------------------------------------------------------
void ofApp::gotFocus(){

}

//--------------------------------------------------------------
void ofApp::gotMemoryWarning(){

}

//--------------------------------------------------------------
void ofApp::deviceOrientationChanged(int newOrientation){

}


void ofApp::audioOut(float *output, int bufferSize, int nChannnels){
    stk::StkFrames synthFrames(bufferSize,1);
    synth->tick(synthFrames);
    for (int i = 0; i < bufferSize; i++) {
        output[2*i] = synthFrames(i,0);
        output[2*i+1] =  synthFrames(i,0);
    }
}


This should just play a note on touch down.

Ahbee avatar May 25 '17 00:05 Ahbee

thanks, will try this tomorrow and get back to you.

ohelli avatar May 25 '17 07:05 ohelli

i decided to go with another option. thanks for your help anyways

ohelli avatar May 29 '17 14:05 ohelli