I work with Cocos2d. This CocosDention not have the property that i need. Maybe anybody know what the way record and save to file all sound using in the current stage on ios. How about DJ app - they keep the music from different pieces and put them on each other.
For example, in the game play background music. When player jumping, cocosdenchion can play jumping sound. Can i create new track combine background music and other music effects realtime and save it?
How i understand AVAudioRecorder only for recording for microphone devices. What i can use for this – AudioToolbox? OpenAL? CoreAudio? Other frameworks?
Before i think use FMOD, but there are license 500$ and i'm not sure my project give me some match money. On this i find free method or framework. Thanks.
preguntado el 28 de agosto de 12 a las 10:08
I found some solution. I use BASS iOS library. one minus – it's paid. And second minus – it's written on C++. And not some example for iOS. But have good help on the forum.
//BASS initialisation. use BASS_free for free resources BASS_Init(-1,44100,0,NULL,NULL); //create mixer BASS_GetInfo(&info); // get output device info. needet to get freq mixer=BASS_Mixer_StreamCreate(info.freq, 2, 0); // create a stereo mixer with the same sample rate NSString *shortSound = [[NSBundle mainBundle] pathForResource:@"piano2" ofType:@"wav"]; //create channel chan2 = BASS_StreamCreateFile(FALSE, [shortSound cStringUsingEncoding:NSUTF8StringEncoding], 0, 0, BASS_STREAM_DECODE); //create channel from file use absolute path url NSString *soundFileName = [[NSBundle mainBundle] pathForResource:@"ff13" ofType:@"mp3"]; chan = BASS_StreamCreateFile(FALSE, [soundFileName cStringUsingEncoding:NSUTF8StringEncoding], 0, 0, BASS_STREAM_DECODE|BASS_SAMPLE_FLOAT|BASS_SAMPLE_LOOP); //add channel into mixer BASS_Mixer_StreamAddChannel(mixer, chan, 0); //point the dirrectory and file name for our new file saved mixer data NSString *documentDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *filename = [documentDir stringByAppendingString:@"/file.mp3"]; //start encode mixer to file when view did load. With parameters for encode. BASS_Encode_StartCAFile(mixer, 'm4af', 'alac', 0, 0, [filename cStringUsingEncoding:NSUTF8StringEncoding]); //mixer add any delay for play added channel. Fix it using this option BASS_ChannelSetAttribute(mixer, BASS_ATTRIB_NOBUFFER, 1); BASS_ChannelPlay(mixer, 0); // start mixer
Here used mixer for record all sounds and microphone voice.