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 int blocksize = 576*4;
23 S32 width=300,height = 300;
24 U16 block[blocksize*2];
31 memset(&swf,0x00,sizeof(SWF)); // set global movie parameters
33 swf.fileVersion = 4; // make flash 4 compatible swf
34 swf.frameRate = 40*256; // about 19 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, blocksize);
51 tag = swf_InsertTag(tag, ST_SOUNDSTREAMBLOCK);
52 for(s=0;s<blocksize*2;s++) {
53 block[s] = 32767 + (int)(32767*sin((s*t*16*3.14159)/blocksize));
55 swf_SetSoundStreamBlock(tag, block, blocksize,1);
56 swf_SetSoundStreamBlock(tag, &block[blocksize], blocksize,0);
57 swf_SetSoundStreamBlock(tag, &block[blocksize], blocksize,0);
58 tag = swf_InsertTag(tag, ST_SHOWFRAME);
61 tag = swf_InsertTag(tag, ST_END);
63 f = open("sound.swf",O_WRONLY|O_CREAT|O_TRUNC, 0644);
64 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
67 swf_FreeTags(&swf); // cleanup