Hey! Is there any way I can maybe shoot some one any Max patches I want looked at through email ? I’m hoping to really dive into using Max as a serious programming tool. I’m learning that it’s no less legitimate of a programming language than python or c++. It’s just higher level, and somewhat limited. I think I could progress really quickly with the plug-in/audio app design process if I just worked out an outline in Max. Then I could get some help with translating it into performance sensitive c++ code.
In the past I have attempted to convert other people’s Max patches into C++ code, and it can be a nightmare depending upon the complexity of the patch.
First problem, is that a lot of the Max components are high level and you can’t find out what the internal logic is for those, which meant that I needed to do research into my text books and online to find out how to write the code for those bits. This is time consuming.
Second problem is that a sophisticated Max patch can have so many connections going all over the place that it can get quite confusing to figure out the structure of the logic.
DSP is pretty hard and you’re either asking for one of two things here. Either (1) you’re seeking the help of an expert DSP coder to spend several hours dealing with the second problem that I mentioned. Or (2) you’re looking for an amateur DSP coder to deal with the first and second problems by spending a few dozen hours on a task for you.
If you’re going for option 1, then you need to offer a very nice hourly rate of pay, because a person with those skills probably already has access to well paying jobs. And if you’re going for option 2 you don’t need to pay as much per hour, but since it will take 5 to 10 times longer, you will probably need to fork out even more money than option 1, to make it worthwhile for them
For small patches could I use Max as an outline for a JUCE app, and not directly look for an exact translation? I have a pretty clear idea of what I want based on a little bit of patching. C++ has a lot syntax that can get in the way of designing a high level structure necessary for building an organized app. Should I use Pd instead?
There are a few recent tools which make Pd really attractive and well suited for prototyping:
Camomile: load Pd patches as VST
vstplugin: Host VST in Pd
Heavy compiler: generate C++ from Pd patches
LibPd: embed Pd patches in other devices
MobMuPlat: embed Pd and build interfaces in Android
Ofelia: OpenFrameworks ported to Pd.
Of course, it’s all free!
Okay. So should I even use Max as an exercise? Or should I just dump it and go with Pd? I want to use Max as tool for small logical structure, but wasn’t really looking to build anything too complicated. I think it’s really hard to see past syntax sometimes and design something truly interesting.
If your end goal is to produce native C++ plugins or applications, it’s best to just bite the bullet now and learn C++. You will be in big trouble trying to “convert” your Max/MSP or PD patches into C++ later. Or finding someone to do it for your for money. Not many people are going to volunteer to do that kind of stuff for cheap. (PD might be slightly better though, as it can also be used as a code library.)
I am not sure what exactly makes the “syntax” of C++ difficult for you? There are obviously design approaches that can make the code look extremely verbose and difficult and that’s usually for reasons of maximum performance and flexibility. But nothing in principle stops you from just writing pretty simple loops and math calculations, if you are going to do the DSP code from scratch. If you need to or want to use 3rd party libraries, then you will need to adapt to their conventions. GUIs are a different matter, and unfortunately most C++ libraries for doing those are at least slightly inconvenient to work with.
So I should essentially be using Max as nothing more than a toy? I have no problem doing c++ I’ve just used Max a lot for school and figured it could be a good tool to brainstorm whatever stuff I want to accomplish in native c++. Specifically I want to build an instrument that can be controlled with some radio buttons and have an array of numbers that switches through an array of synths either at random or in serial. I didn’t come up with this until I started dinking around in Max.
Since you know Max well enough to make things, there logically can’t be anything stopping you from testing/generating ideas with it.
However, if you want to translate your patches to something else, I think that you will need to learn how it really works so that you can mimic your creations in your target language(s).
My advice would be to go with whatever design approach you find quickest and easiest, and choose a final architecture based upon the needs of your project(s).
Also one approach might be to start with Max/MSP and then gradually replace all objects with custom Max external modules written in C / C++ which do the same thing until you have just one master C object that should be native C++ for exporting (Disclaimer: I don’t have tried this myself, so there might be many pitfalls and you might have to work against the Max External object API, however this Divide & Conquer approach might divide the transformation to C++ into more approachable chunks).
So in other words it’s almost more complicated to proto type in Max than simply writing code in c++ and making it gradually more complicated.
Depending on the kind of algorithm you design, Max can definetively help you to achieve a quick proof of concept and make things audible. For an example, I used it some time ago to build up some guitar distortion algorithms, it was a really great workflow to just put a signal path together, plug in a guitar and tweak parameters, e.g. simply put some filter here or build up a parallel path there… I think I wouldn’t have come up with such a good sounding result after a relatively short development time if I had written plain C++ in the first place. However after that, implementing the whole thing in C++ was basically redoing everything except for the fact that I already had found out what signal chain and combination of parameters sounded the best, so that I could focus on an elegant implementation.
So you could see it as a tool mainly for the creative part of the work, but not as a tool that speeds up any part of the actual implementation work.
In my experience, there were different stages that I went through as a DSP developer. At first, I was learning why things worked. And so, looking under the hood of Max can be an interesting exercise. If you’re at the learning stage, then there’s always a benefit to exploring because it sharpens your mind.
But once you progress to the serious stage, and you actually want to get something done, you’re going to want to spend as much time as possible in whatever language the project will be released in. Its really annoying to jump between different languages and find that there are bugs introduced during the translation process.
For example, I have built my own library of C++ classes so that if I ever want to create a new plugin, I can re-use bits and pieces of my old code. I stopped sketching out ideas in C# even though its easier to code in. And because I’ve used it so many times the bugs have mostly been ironed out. Another advantage, is that thinking in C++ just makes your mind sharper over time. Max makes your brain lazy. Its like driving an automatic car with cruise control.
Okay, so maybe I should grab a sheet of paper or some sort of outline and just use that as my anchor. Then if I’m stuck, which I am I can use that as a way to seek guidance. Fir example I’d like to be able to to control a white noise generator and toggle it between two or three different synths, with an array cycling through numbers. I know in Max I would multiply the signal by a 1 or a zero for each synth. In JUCE I can’t even turn my noise generator off and on after I got it working. Where do I get started with controlling my oscillator after it’s working?
I then what to envelope the signal with values I can control with a set of sliders.
It’s impossible to say without knowing more specifics about how the noise generator has been implemented. This is obviously a problem with a general purpose programming language like C++, things can be implemented in countless ways and it’s difficult to give any advice without seeing the specific code involved. (You also didn’t mention if you are doing this in a plugin/AudioProcessor or standalone application context. It doesn’t matter very much but there are some details that can be a bit different depending on your project type.)
But the principle for muting/unmuting is obviously the same as in Max/MSP, just multiply the signal by 1.0 to have it on, and multiply by 0.0 to turn it off. (This is not taking into account any optimizations that could and probably should be done.)
Okay so according to the tutorial I built a white noise generator, and the codes kind of long. I want to be able to create as many instances of this generator as I want and use a GUI to create radio buttons that turn different generators off and on. I want some that are filtered, and some with a different amplitude enveloping. I basically want to build a small synth from scratch.
If you mean the JUCE “Build a white noise generator” tutorial, that’s not really about making a proper noise generator/oscillator that you can have multiple instances of, control parameters and so on, that code just directly outputs random numbers into the audio hardware output. The bulk of the code just deals with getting a windowed application with audio running. They put in the full DSP code directly into the getNextAudioBlock method because there’s not much to do. But in a real plugin or application you would have separate classes for the oscillators, filters and even volume changes/muting. Then the getNextAudioBlock or processBlock method would call methods in the instances of those classes (“objects”) in the right order to generate the output. Also, if you are planning on making a synthesizer, you might want to look into the JUCE Synthesiser related classes.
Okay so we’ve identified the question. Do I want to create classes of my own that call the hardware and use control parameters on that?
You want to create classes that process the audio samples (or MIDI messages). JUCE already has the classes that interface with the audio and MIDI hardware. (Or with the host application when you are doing a VST or similar plugin.) You will just be reusing or customizing those by subclassing.
JUCE also has some classes for oscillators, filters, a simple ADSR envelope and so on. You may be able to get something done with those but you will likely also need to look for 3rd party code or write some from scratch.
Here’s a slightly more real life example of a JUCE AudioAppComponent based application that generates noises. The noise generation has been encapsulated into a separate class that also deals with the noise output volume and enveloping it with the JUCE simple ADSR envelope. The main application component uses 2 instances of the class to allow generating the noise separately to the left and right channels. There are also 2 toggle buttons in the GUI to turn the noises on and off. The code is not an example of any best practices and likely has some mistakes. It is only meant to demonstrate some of the stuff I’ve mentioned in this forum thread.