--- /dev/null
+/* swfaction.c
+
+ SWF Sound handling routines
+
+ Extension module for the rfxswf library.
+ Part of the swftools package.
+
+ Copyright (c) 2001, 2002 Matthias Kramm <kramm@quiss.org>
+
+ This file is distributed under the GPL, see file COPYING for details
+
+*/
+
+#include "../rfxswf.h"
+
+void swf_SetSoundStreamHead(TAG*tag, U16 avgnumsamples)
+{
+ U8 playbackrate = 3; // 0 = 5.5 Khz, 1 = 11 Khz, 2 = 22 Khz, 3 = 44 Khz
+ U8 playbacksize = 0; // 0 = 8 bit, 1 = 16 bit
+ U8 playbacktype = 1; // 0 = mono, 1 = stereo
+ U8 compression = 2; // 0 = raw, 1 = ADPCM, 2 = mp3
+ U8 rate = 3; // 0 = 5.5 Khz, 1 = 11 Khz, 2 = 22 Khz, 3 = 44 Khz
+ U8 size = 0; // 0 = 8 bit, 1 = 16 bit
+ U8 type = 1; // 0 = mono, 1 = stereo
+
+ swf_SetU8(tag,(playbackrate<<2)|(playbacksize<<1)|playbacktype);
+ swf_SetU8(tag,(compression<<4)|(rate<<2)|(size<<1)|type);
+ swf_SetU16(tag,avgnumsamples);
+}
+
+void swf_SetSoundStreamBlock(TAG*tag, U16*samples, int numsamples)
+{
+ CodecInitOut * init;
+ CodecInitIn params;
+ char*buf;
+ int len = 0;
+
+ if(!buf)
+ return;
+
+ memset(¶ms, 0, sizeof(params));
+ params.frequency = 44100; //48000, 44100 or 32000
+ params.mode = 0; //0 = Stereo, 2 = Dual Channel, 3 = Mono
+ params.emphasis = 0; //0 = None, 1 = 50/15 microsec, 3 = CCITT J.17
+ params.bitrate = 128; //default is 128 (64 for mono)
+
+ init = codecInit(¶ms);
+ printf("nSamples:%d\n", init->nSamples);
+ printf("bufferSize:%d\n", init->bufferSize);
+
+ buf = malloc(init->bufferSize);
+
+ len = codecEncodeChunk(numsamples, samples, buf);
+ len += codecFlush (&buf[len]);
+ len += codecExit(&buf[len]);
+
+ swf_SetBlock(tag, buf, len);
+ free(buf);
+}
+