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)
23 S32 width=300,height = 300;
31 memset(&swf,0x00,sizeof(SWF)); // set global movie parameters
33 swf.fileVersion = 4; // make flash 4 compatible swf
34 swf.frameRate = 18*256; // about 18 frames per second
36 swf.movieSize.xmax = 20*width; // flash units: 1 pixel = 20 units ("twips")
37 swf.movieSize.ymax = 20*height;
39 swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
46 tag = swf_InsertTag(tag, ST_SOUNDSTREAMHEAD2);
47 swf_SetSoundStreamHead(tag, 11025/18);
51 tag = swf_InsertTag(tag, ST_SOUNDSTREAMBLOCK);
52 for(s=0;s<blocksize;s++) {
53 block[s] = (int)(32767*sin(s*8*3.14159/blocksize));
54 if(t==0) block[s] = 0;
56 swf_SetSoundStreamBlock(tag, block, 1);
57 tag = swf_InsertTag(tag, ST_SHOWFRAME);
60 tag = swf_InsertTag(tag, ST_END);
62 f = open("sound.swf",O_WRONLY|O_CREAT|O_TRUNC, 0644);
63 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
66 swf_FreeTags(&swf); // cleanup