Maximilian - some C++ objects for dsp and synthesis

Hi There,

I wanted to ‘officially’ announce my MIT-licensed audio synthesis library, maximilian. I wrote most of it over christmas holiday. It’s pretty flexible and designed to be easy to use. It’s named after my 6 month old son, as he’s a big fan of resonant low pass filters.

You can download an XCode project and an oF addon here.

http://www.maximilian.strangeloop.co.uk/

The oF addon was created by Arturo Castro back in January (thanks Arturo!). I’ve not really tested it properly, although I’ve fixed a few bugs in the main library since then, and the sample playback works in reverse now. There’s some tutorials to show you how it works, and they’re pretty easy to follow I hope.

If anyone is interested in contributing to the library, feel free to contact me at m.grierson@gold.ac.uk. I don’t have a great deal of time, but wanted to contribute something to the community that could be built on if people found it useful.

Warm regards,

Mick

Hey!

Thanks a lot for this, is just that i was looking for.

The next line can be useful to compile it on linux.

  
g++ -Wall -D__LINUX_ALSA__ main.cpp RtAudio.cpp maximilian.cpp -lasound -lpthread  

A question, how to deal with the input with maximillian?

once more, thanks!


brolin

I’ve tried this out and it’s really awesome :slight_smile:
Thanks, this is exactly what OF needed!

demo is very cool.
looking forward to doing some real time synths in future projects.

just had a bit of trouble running the oF example at first,

had to rename,

~sample() to ~maxiSample()
sample() to maxiSample()
sample(char* tmpPath) to maxiSample(char* tmpPath)

also had to comment out,

maxiOsc::maxiOsc(){
// memset(phases,0,500);
// memset(freqs,0,500);
}

was saying that phases and freqs was not being declared.

am i missing a file or something?

L.

Hi there,

Thanks for the comments. Sorry for the late response.

For even more info for compiling with RtAudio, you can see this page here:

http://www.music.mcgill.ca/~gary/rtaudio/compiling.html

Also, you can compile using portaudio - download and compile the portaudio lib, include it in the project, and then switch

//#define MAXIMILIAN_PORTAUDIO
#define MAXIMILIAN_RT_AUDIO

to

#define MAXIMILIAN_PORTAUDIO
//#define MAXIMILIAN_RT_AUDIO

I’ll sort out the audio input callback as soon as I can (not difficult - just time is an issue).

@julapy - thanks for sorting out the errors in maxiSample for ofxMaximilian. I’ve updated the svn and zipfile on the website.

For 0.2, my priorities are improving the sample player interpolation, creating the the granular sample player (for timestretching), and new / better filters. If I have time, I’ll do a phase vocoder, as this isn’t too hard but will be very useful. Let me know what else would be good, and I’ll see what I can do.

Regards,

Mick

Feature requests…hmmm dangerous :wink:

So…

feature requests…

Granular synth with randomness / jitter. Sounds like a great idea. I’m going to make this a priority.

More audio formats are on the way.

You can already do realtime setting of loop points on samples. You can set the start and end point with sample.play(float speed,float start,float end). You can do basic timestretching this way if you want. It sounds like those old 90’s timestretchers. You might also try messing about with the envelope here. Also, if you pass in a few waveforms as start points, constrain them between 0 and 1, then multiply by beats.length(), things get really funky and mental.

As for HRTFs, yes, I’m sure that would be pretty simple using the delay line.

am i the only one who can’t find the link to download the OF addon?
any way downloaded the C++ lib and it looks great! well done :slight_smile:

Rui

*edit* ok, this is what i get by checking this out at 4AM! the addon is bundled with the download… DOH!!

Thank you so much for this code, it is really helping with our project!

We are using 8 channels out for our project and I spent a while trying to figure out why I was having problems with ambisonic mixing … So I found the solution and thought I would share for people who are using more than the standard stereo pair of speakers.

Not only do you need to setup the ofSoundStream and the ofxMaximilian to have 8 outs, but you also need to make sure you update the maximilian.h file on line 355 from double lastValues[2] to double lastValues[8] .

Just an FYI to any interested in using Maximilian on iPhone:

As far as I can tell, the iPhone’s soundStream class does not presently create audio events, which Maximilian depends on to do its magic. Fortunately, you can get it working quick and dirty with a little re-routing.

Merely implement audioRequested in your main app class like this:

  
  
ofAudioEventArgs audioEventArgs; // Static variable  
  
void testApp::audioRequested(float * output, int bufferSize, int nChannels) {  
    audioEventArgs.buffer = output;  
    audioEventArgs.bufferSize = bufferSize;  
    audioEventArgs.nChannels = nChannels;  
    maxi.audioRequested(audioEventArgs);  
}  
  

And you should be good to go!

I’m sure there are 99 more elegant ways to do this, but this is my late-night noob attempt to get things rolling quick :slight_smile:

Hi all,

We are having trouble setting the audio input to be processed with Maximilian.
Any clue to deal with this.

Our try was in OF, mixing the audioInputExample with the maximilian code, but we had no success.

Any help will be appreciated

b

Hi,

I’ve been playing with this for the last few days. It’s really awesome. Really.

Is there any documentation that explains the less intuitive features?

For example : how do the envelopeData arrays work? What does the envelope.line function expect in there?

And on maxiSample::play(double frequency, double start, double end), are start/end in seconds, or samples? What is frequency? How often the sample is looped?

Is there a way to not loop the samples? The sample example says it loops by default, but I don’t see a way to change that.

Did I miss the docs somewhere?

Any help is greatly appreciated.

Thanks.
Thiago

Hi Thiago,

There is no documentation at the moment, and Mick is a very busy person so he hasn’t had much time to flesh out the rest of his project. The best thing to do is experiment and try out things in order to understand them.

Regarding the sample looping, I re-used the sampler code from Maximilian to make a stand-alone sampler object for OF. In that code I’ve added features to control looping, play in reverse and some other stuff. It’s here:
http://forum.openframeworks.cc/t/example-of-playing-back-a-sample-in-ofsoundstream/3502/0
If you wanted to it should be easy to incorporate my changes back into Maximilian.

I am having some difficulties running this on iphone, when I add the audio events to the audioRecieved function, it causes my app to crash. I tried casting my float buffer to a double buffer and passing it directly into the play function, but that just played back really low static. I wonder if anyone could give me any pointers?

Hi Everyone,

Wow. Haven’t been here for a while. Thanks everyone for your interest. Sorry for not being around. Thanks for your understanding and patience.

Got some good news.

We’ve got a new version of Maximilian, complete with a proper, tested, really working (i promise) ofaddon called ofxMaxim. This is fully compatible with ofxiPhone too, and has working fft and ifft classes, with examples. It also uses the accellerate framework for the ffts so does very well. There’s much more to come also, as now we have Chris Kiefer on the team…

Got to thank Digital Star and Arturo for their enthusiasm, time and effort too.

Finally, though, Chris deserves a lot of credit. Anyhow. Here’s a link to the svn for ofxMaxim. tested on iPhone, OSX, Linux and Windows visual studio. Let us know if you have any problems and I’ll keep an eye on the thread I promise!

just go to your command line and do

svn co https://igor.gold.ac.uk/svn/mus02mg-MaximilianOF/

or go to http://www.maximilian.strangeloop.co.uk

Cheers

Mick

Hey Dr_MG,

I downloaded your examples of maximilian but it don’t seem to work with the iPhone’s openFraneworks version.

Can you point me a litlle bit or
can you do an exemple for the community?

I’m now using OpenAL… Your addon seems to be a lot more usefull for my project!

Thanks a lot in advance.

It makes me ten errors when I put

#include “ofxMaxim.h”

in my ofxiPhone project:

Ld build/Debug-iphonesimulator/touchAndAccelExample.app/touchAndAccelExample normal i386
cd /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH “/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin”
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g+±4.2 -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.1.sdk -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/build/Debug-iphonesimulator -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/freetype/lib -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/freeimage/lib -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/gluIphone -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/FreeImage/lib/iphone -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/FreeImage/lib/linux -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/FreeImage/lib/linux64 -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/FreeImage/lib/osx -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/FreeImage/lib/vs2008 -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/FreeImage/lib/win_cb -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/freetype/lib/iphone -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/freetype/lib/linux -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/freetype/lib/linux64 -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/freetype/lib/osx -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/freetype/lib/vs2008 -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/freetype/lib/win_cb -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/glu/lib/iphone -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/glu/lib/vs2008 -L/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/glu/lib/win_cb -L/Developer/openFrameworks/libs/poco/lib/armv6 -L/Developer/openFrameworks/libs/poco/lib/linux -L/Developer/openFrameworks/libs/poco/lib/linux64 -L/Developer/openFrameworks/libs/poco/lib/osx -L/Developer/openFrameworks/libs/poco/lib/vs2008 -L/Developer/openFrameworks/libs/poco/lib/win_cb -F/Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/build/Debug-iphonesimulator -filelist /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/build/iPhoneTouchAndAccelExample.build/Debug-iphonesimulator/touchAndAccelExample.build/Objects-normal/i386/touchAndAccelExample.LinkFileList -mmacosx-version-min=10.6 -ObjC -w -Xlinker -objc_abi_version -Xlinker 2 -framework Foundation -framework UIKit -framework CoreGraphics -framework OpenGLES -framework QuartzCore -framework AudioToolbox -framework OpenAL -framework CoreLocation -lFreeImage_iphone_universal -lFreeType_iphone_universal -lGLU -lGLU_arm “/Applications/of_preRelease_v0061_iPhone_FAT-pre3/libs/openFrameworksCompiled/lib/iphone/libofxiPhoneOFLib_iphonesimulator _Debug.a” /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/poco/lib/armv6/CppUnit.a /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/poco/lib/armv6/PocoFoundation.a /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/poco/lib/armv6/PocoNet.a /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/poco/lib/armv6/PocoUtil.a /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/poco/lib/armv6/PocoXML.a /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/poco/lib/osx/CppUnit.a /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/poco/lib/osx/PocoFoundation.a /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/poco/lib/osx/PocoNet.a /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/poco/lib/osx/PocoUtil.a /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/…/…/…/libs/poco/lib/osx/PocoXML.a -o /Applications/of_preRelease_v0061_iPhone_FAT-pre3/apps/iPhoneSpecificExamples/_newBal_Colors/build/Debug-iphonesimulator/touchAndAccelExample.app/touchAndAccelExample

Undefined symbols:
“_vDSP_rect”, referenced from:
fft::inversePowerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
“_vDSP_polar”, referenced from:
fft::powerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
“_ctoz”, referenced from:
fft::inversePowerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
fft::powerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
“_vmul”, referenced from:
fft::inversePowerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
fft::powerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
“_ztoc”, referenced from:
fft::inversePowerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
fft::powerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
“_destroy_fftsetup”, referenced from:
fft::~fft() in fft.o
fft::~fft() in fft.o
“_create_fftsetup”, referenced from:
fft::fft(int)in fft.o
fft::fft(int)in fft.o
“_vDSP_vdbcon”, referenced from:
fft::powerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
“_fft_zrip”, referenced from:
fft::inversePowerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
fft::powerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
“_vsmul”, referenced from:
fft::inversePowerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
fft::powerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
fft::powerSpectrum_vdsp(int, float*, float*, float*, float*)in fft.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Do you have an Idea?

Hi moulitz,

Yeah I spotted a small error in the ofx for iPhone today which is what might be causing your error. We’ve got a working version but tweaked it a bit to make a universal ofx that worked both on the desktop and iPhone and although it works on our machines, there’s a small difference which we need to iron out. Give me a day or so and I’ll post a fix. Also, I’ll include some nice fft examples on the iPhone, with some other simple tutorials etc.

Sorry about this. Promise to have it sorted in a day or so. Thanks for your patience.

Regards,

Mick

OK - here’s the fix

basically, if you’re on a mac or on the iPhone, maximilian expects to find the accelerate framework. You need to add this framework to your xcode projects. That’s what is causing your errors. Just add the framework in the normal way (go to libs - core - core frameworks, right click, add > existing frameworks > accelerate)

If you’re on windows, it falls back to maximilian’s own FFTs. Not quite as fast, but totally fine.

Regards,

Mick

I receive random EXC_BAD_ACCESS, and I think there’s something wrong in maxiFFT::setup:

window = (float*) malloc(fftSize * sizeof(float));
memset(window, 0, fftSize * sizeof(float));

shouldn’t it be windowSize here instead of fftSize?