3 Generates a sine wave and tries to create an swf which
6 Part of the swftools package.
8 Copyright (c) 2002 Matthias Kramm <kramm@quiss.org>
10 This file is distributed under the GPL, see file COPYING for details
16 #include "../rfxswf.h"
18 int main (int argc,char ** argv)
22 S32 width=300,height = 300;
25 FILE* fi = fopen("test.mp3","wb");
26 FILE* fi2 = fopen("test2.wav","wb");
32 memset(&swf,0x00,sizeof(SWF)); // set global movie parameters
34 swf.fileVersion = 4; // make flash 4 compatible swf
35 swf.frameRate = 19*256; // about 19 frames per second
37 swf.movieSize.xmax = 20*width; // flash units: 1 pixel = 20 units ("twips")
38 swf.movieSize.ymax = 20*height;
40 swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
47 tag = swf_InsertTag(tag, ST_SOUNDSTREAMHEAD2);
48 swf_SetSoundStreamHead(tag, 1152);
52 tag = swf_InsertTag(tag, ST_SOUNDSTREAMBLOCK);
53 for(s=0;s<1152*2;s++) {
54 block[s] = (int)(32767*sin((s*16*3.14159)/1152));
56 swf_SetSoundStreamBlock(tag, block, 1152,1);
57 swf_SetSoundStreamBlock(tag, &block[1152], 1152,0);
58 fwrite(&tag->data[4], tag->len-4, 1, fi);
59 fwrite(block, 1152*2*2, 1, fi2);
60 tag = swf_InsertTag(tag, ST_SHOWFRAME);
65 f = open("sound.swf",O_WRONLY|O_CREAT|O_TRUNC, 0644);
66 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
69 swf_FreeTags(&swf); // cleanup