I also thought to Sound.extract, but the question is : how to combine
byteArray with my mixing?
Here is what i've done :
> public function playNote(id:String):void
> {
> //My note
>
> mySound=myMC.getSound(id) as Sound;
>
> mySound.play();
>
> outputSound=new Sound();
>
> outputSound.addEventListener(SampleDataEvent.SAMPLE_DATA,
> onSampleData);
>
> outputSound.play();
> }
> public function onSampleData(e:SampleDataEvent):void
> {
> //Datas extraction, put in _samplesOut (byteArray)
>
> mySound.extract(_samplesOut, 44100*(mySound.length/1000));
>
> //stock is an Array
> stock.push(_samplesOut);
> }
> public function savesThisShit():void
> {
> var encoder:WAVEncoder = new WAVEncoder ( );
>
> var fileRef:FileReference = new FileReference ( );
>
> fileRef.save( encoder.addHeaders ( testConvert(stock) ),
> "mySample.wav" );
> }
> //@Param is my stock Array (content is all byteArray)
> private function testConvert( arr:Array ):ByteArray {
>
> var ba:ByteArray = new ByteArray ( );
>
> ba.endian=Endian.LITTLE_ENDIAN;
>
> //For every byteArray
> for(var i:uint=0; i<arr.length; i++)
>
> {
> (arr[i] as ByteArray).position=0;
>
> //I put every byteArray in a unique one which will be exported
> as wav file
> while ( (arr[i] as ByteArray).position < (arr[i] as
> ByteArray).length ) {
>
> ba.writeShort( (arr[i] as ByteArray).readFloat ( ) *
> 32767);
>
> }
> }
>
> return ba;
> }
>
>
But as you can guess, i get one note at a time, not a real composition.
2011/2/17 Henrik Andersson <[email protected]>
> Pierrick Pluchon skriver:
>
> Hi List,
>>
>> I'm currently working on a little musical app with multiple sounds. Think
>> of
>> it like a piano - each key plays a different note. What i'm trying to do
>> is
>> to record my whole composition as a byteArray and to export it as wav
>> file.
>> The export is ok, i get good results when I play one note at a time, but
>> when I play more than one note at a time, the notes come out separately,
>> instead of as a chord.
>> I thought i could use SoundMixer.computeSpectrum(), but it doesn't work,
>> or
>> at least i get a really shitty sound.
>> Any suggestions?
>>
>
> Sound.extract combined with your own mixing.
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders