How export generated sound into audio file

TheAvenger's icon

Hi guys, i've a problem. I created a keyboard application that records what i play, but i can listen the melody only through the max application. I just want to export the sound into an audio file, for example mp3 file. How can i do?

Edit: oh well, i found the way to export the audio through "write" element. The application saves it as a midi file, there's someway to export as mp3?

Peter Castine's icon

If you're using MSP, you'd use sfrecord~. But it sounds like your patch is just generating MIDI that is being rendered by your computer (ie, by the OS and audio hardware, and not by Max/MSP). You could re-route the sound card output with Soundflower or similar and then record to sfrecord~.

Last time I looked sfrecord~ would only save non-compressed audio (AIFF, WAV, etc.) and not MPEG3. There are a number of standalone apps that will convert non-compressed to compressed audio for you, though. For instance, iTunes.

TheAvenger's icon

Thany u very much for answering. Aiff or wave format are good for me, but i really don't understand how to record the midi sound generated from my keyboard application and save it on pc in aiff/wave through "sfrecord". I'm reading a tutorial and it says:
"sfrecord~ records to disk whatever signal data it receives in its inlets. The signal data can come directly from an adc~ or ezadc~ object, or from any other MSP object."
Well i made as shown in the example.. how i have to do? Here is my example patch.

3747.prova.maxpat
Max Patch
brendan mccloskey's icon

Hi
your patch demonstrates an error in understanding: MIDI is not sound.

Your Max patch is generating MIDI numbers (notes, velocity etc) which are sent to a MIDI synth - your computer has one built into the soundcard.

[sfrecord~] is for recording AUDIO only, and as Peter says, you need some way to route the audio from this MIDI synth back into MaxMSP.

There is no way in Max alone to record audio output of a non-native GM synth. I've never used the [vst~] object but perhaps you can plug a synth in here and get audio output?

This patch is a quick fix, and sounds sh*te because it's recording the laptop mic picking up the speakers' output.

Max Patch
Copy patch and select New From Clipboard in Max.

Brendan

TheAvenger's icon

Thank u. So MIDI is a set of informations sent to PC MIDI synth, and i need to turn back the audio to max? I found this
http://www.ewanhemingway.co.uk/blog/howto-route-midi-between-maxmsp-and-virtual-synths
it might be a solution? Anyway in this case (where i download this application) it's only me that can export the generated sound as a aiff/wave file right? No one could do the same using my patch on your own PC.

brendan mccloskey's icon

If you're referring to LoopBe, this app passes MIDI to/from another DAW or audio program. Audio re-routing needs something else, like Soundflower - which I think is Mac only. I think. Not aware of any PC version, but you could always just buy a cheap external soundcard and connect out to in (carefully).....

seejayjames's icon

I've heard of "Jack" for Windows, which routes audio. Should be OK. Also the vst~ is an option, though each will have its own sounds. If you want the General MIDI sounds that you're getting right now, the easiest option is to have another computer record it :) I would use Audacity, which can convert to mp3 as well, with the encoder installed.

TheAvenger's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Thank u all for the informations. Anyway i think i'll follow the vst way, 'cos i wanna my patch be universal. I'm checking it, here is the patch. I'm sure i'm wrong 'cos i don't know well how to link kslider to vst, and i'm not sure if "s_ tosvts_" is necessary too. I know i'm a noob. Any help will be much appreciated.

seejayjames's icon

no Max here so I can't see the patch, but just be sure you're sending "midievent" commands to the vst~ object. so

midievent 144 60 100 = noteon channel 1 middle C at velocity 100
midievent 144 60 0 = noteoff of the same (velocity 0 = noteoff)

hopefully I remembered that right ;)

TheAvenger's icon

Thanks i inserted them, but now i need to know how to play vst with kslider. Please help!

TheAvenger's icon

Ok guys i made it, but now just a curiosity. If i save an application there's the possibility to "save" the vst instrument i loaded? I mean.. i would that vst could be always loaded in the patch everytime i open it, without load it everytime i use the saved application through the "plug" message.

nix808's icon

@THE AVENGER,
if you type the name of the plugin in the vst object after vst~, it will load it again