Hesitating about choosing a sound addon for my iOS stuff...

Hi there,
I’m looking for a reliable library to implement a very light synthesizer for iOS purpose.
I already have low-level dsp c++ code to implement delays & things like that, but I’d like to know if there was a lib including that too.

I tested Maximilian, the core features of OF too.
I didn’t have a lot of chance with Maximilian and I read about ofSoundStream but a lot of people focuse on Maximilian

Anyone on this?
I’m on this right now
If I have news, I’ll post here

Both will allow you to actually synthesize sound as they give you low level access to the system sound buffer, but if you want some help with the math behind creating music out of an array of floating point numbers, you want Maximilian. If you know all the DSP math yourself, then you can just go ahead and use ofSoundStream.

Hi Joshua,
and thx for your anwer.

where is ofSoundStream ?
is it based on Maximilian ?

About Maximilian

I tried to start from an empty example.
I added the ofxMaxim folder (w/ src inside etc) in the addons virtual folder in the XCode project.
ok
Of course, before, I copied the addon into the addons folder of my OF Root.
I pasted the code of the 1st tuto (https://github.com/micknoise/Maximilian/blob/master/maximilian-examples/1.TestTone.cpp) into my testApp.mm
I added the prototype into testApp.h etc.
Included “ofxMaxim.h”
No more errors in the code.

Then, I’m trying to compile and …
that error.
I’m almost despaired :-/

(almost I wrote)

ofSoundStream is part of the openframeworks library, you’ll see it in openframeworks/libs/openframeworks/sound. There’s (some) documentation on how it works here: http://www.openframeworks.cc/documentation/sound/ofSoundStream.html

For maximilian, take a look at the OF specific examples here: https://github.com/micknoise/Maximilian/tree/master/ofxMaxim

Also, in the future, can you try to put questions like this in beginner rather than advanced? Thanks!

sorry for the bad place ; indeed, I saw other questions like that here so I fired them mine :-/

about the examples.
I succeeded with the (only) one matching iOS + 007.
It works and play a sample in the simulator (and on the gear too…)

But my problem is the others tutos…
noone works here and I cannot figure out what, in my process, is the cause :-/

The cause is that the non-OF examples are not OF examples, they’re for pure C++. You can use them with OF by using the OF example as a template and copying the classes needed and functionality into your app.

Ok I got it.
By copying, you mean taking those cpp files, building .h files, then call (instantiate I guess) in testApp.mm ?

Believe me, joshua, I succeeded with other addon (and classes too) but not with that one :-/
I mean, I’m trying a lot.

Especially, audioRequested has to be involved.
How can I … play that 440hz sine using the first tuto + the emptiest example of the world ?

your help is very appreciated.

.h

  
#pragma once  
  
#include "ofMain.h"  
#include "ofxMaxim.h"  
  
class testApp : public ofBaseApp{  
  
	public:  
	  
	testApp();   
		void setup();  
		void update();  
		void draw();  
  
        void audioOut(float * output, int bufferSize, int nChannels);  
      
        maxiOsc mySine;  
		  
};  
  

.cpp

  
#include "testApp.h"  
  
  
testApp::testApp(){  
}  
  
void testApp::setup(){  
    ofSoundStreamSetup(2,0,this, 44100, 512, 4);/* Call this last ! */  
}  
  
void testApp::update(){  
  
}  
  
void testApp::draw(){  
  
}  
  
void testApp::audioOut(float * output, int bufferSize, int nChannels) {  
    *output=mySine.sinewave(440);//simple as that!   
}  

thanks a lot joshua.

It doesn’t compile.
I took the legacy emptyExample for iPhone.
I made all my tests with it and I could draw on the screen, use the ofxUI toolkit etc.

I exactly did the same (+ the thing you taught to me here)
It doesn’t compile

main.mm still remains the bootstrap in that case right?

main.mm

  
#include "ofMain.h"  
#include "testApp.h"  
  
int main(){  
	ofSetupOpenGL(1024,768, OF_FULLSCREEN);			// <-------- setup the GL context  
  
	ofRunApp(new testApp);  
}  
  

testApp.mm

  
#include "testApp.h"  
  
//--------------------------------------------------------------  
void testApp::setup(){	  
	// register touch events  
	ofRegisterTouchEvents(this);  
	  
	// initialize the accelerometer  
	ofxAccelerometer.setup();  
	  
	//iPhoneAlerts will be sent to this.  
	ofxiPhoneAlerts.addListener(this);  
	  
	//If you want a landscape oreintation   
	//iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT);  
	  
	ofBackground(127,127,127);  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
	  
}  
  
//--------------------------------------------------------------  
void testApp::exit(){  
  
}  
  
//--------------------------------------------------------------  
void testApp::touchDown(ofTouchEventArgs &touch){  
  
}  
  
//--------------------------------------------------------------  
void testApp::touchMoved(ofTouchEventArgs &touch){  
  
}  
  
//--------------------------------------------------------------  
void testApp::touchUp(ofTouchEventArgs &touch){  
  
}  
  
//--------------------------------------------------------------  
void testApp::touchDoubleTap(ofTouchEventArgs &touch){  
  
}  
  
//--------------------------------------------------------------  
void testApp::lostFocus(){  
  
}  
  
//--------------------------------------------------------------  
void testApp::gotFocus(){  
  
}  
  
//--------------------------------------------------------------  
void testApp::gotMemoryWarning(){  
  
}  
  
//--------------------------------------------------------------  
void testApp::deviceOrientationChanged(int newOrientation){  
  
}  
  
  
//--------------------------------------------------------------  
void testApp::touchCancelled(ofTouchEventArgs& args){  
  
}  
  
  

testApp.h

  
#pragma once  
  
#include "ofMain.h"  
#include "ofxiPhone.h"  
#include "ofxiPhoneExtras.h"  
  
class testApp : public ofxiPhoneApp {  
	  
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);  
  
};  
  
  
  

tone.cpp

  
#include "testApp.h"    
  
  
testApp::testApp(){    
}    
  
void testApp::setup(){    
    ofSoundStreamSetup(2,0,this, 44100, 512, 4);/* Call this last ! */    
}    
  
void testApp::update(){    
      
}    
  
void testApp::draw(){    
      
}    
  
void testApp::audioOut(float * output, int bufferSize, int nChannels) {    
    *output=mySine.sinewave(440);//simple as that!     
}    

tone.h

  
#pragma once    
  
#include "ofMain.h"    
#include "ofxMaxim.h"    
  
class testApp : public ofBaseApp{    
      
public:    
      
    testApp();     
    void setup();    
    void update();    
    void draw();    
      
    void audioOut(float * output, int bufferSize, int nChannels);    
      
    maxiOsc mySine;    
      
};  

No, you need to put the stuff I added in the .cpp to the .mm file. Take a look at some of the iPhone example applications so you can see how to use OF on the iPhone, read through the code on a few of them, see how they’re structured, then try to add in extra functionality.

I’m sorry but, I really did and tested a lot of examples without being stuck like here :-/
It happens, when you learn.

I have to say it doesn’t work here.
It was what I did before as I wrote.
I don’t want to take your time too much. I’ll dig that again deeper right now

(in your code, I guess maxiOsc mySine; should be ofxMaxiOsc mySine; even if I think it can be the same, I’d prefer to be sure)

I retested, this Maximilian’s first tuto doesn’t work with iOS emptyExample. (20 errors …)
What did I miss ? this is the question.
If I can succeed, I’ll inform you and post my way.

And finally I solved it.
I don’t know if it is a Xcode, a simulator or whatever related BUT, the Accelerate.framework lib HAS TO be linked.
Without this one, Maximilian doesn’t compile for iOS

It should be written somewhere

Here is the post : http://julienbayle.net/2012/03/01/maximilian-audio-library-openframeworks-ios/

Glad you figured it out. It’s weird, I thought Accelerate didn’t need to be linked against any more. Maybe just for iOS. Still it’d be good if they’d include a note about that in the library. Have fun!

It is probably related to FFT as far as I read here

btw, it means I can now … begin :slight_smile: