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 program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
27 #include "../rfxswf.h"
29 int main (int argc,char ** argv)
34 S32 width=300,height = 300;
42 memset(&swf,0x00,sizeof(SWF)); // set global movie parameters
44 swf.fileVersion = 4; // make flash 4 compatible swf
45 swf.frameRate = 18*256; // about 18 frames per second
47 swf.movieSize.xmax = 20*width; // flash units: 1 pixel = 20 units ("twips")
48 swf.movieSize.ymax = 20*height;
50 swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
57 tag = swf_InsertTag(tag, ST_SOUNDSTREAMHEAD2);
58 swf_SetSoundStreamHead(tag, 11025/18);
62 tag = swf_InsertTag(tag, ST_SOUNDSTREAMBLOCK);
63 for(s=0;s<blocksize;s++) {
64 block[s] = (int)(32767*sin(s*8*3.14159/blocksize));
65 if(t==0) block[s] = 0;
67 swf_SetSoundStreamBlock(tag, block, 1, 0);
68 tag = swf_InsertTag(tag, ST_SHOWFRAME);
71 tag = swf_InsertTag(tag, ST_END);
73 f = open("sound.swf",O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644);
74 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
77 swf_FreeTags(&swf); // cleanup