Main Page | Data Structures | File List | Data Fields | Globals

ex12.c

00001 /*=========================================================================
00002 
00003 GFX EXAMPLE CODE - #12
00004         "PSG sound"
00005 
00006 Copyright (C) 2004  Rafael de Oliveira Jannone
00007 
00008 This example's source code is Public Domain.
00009 
00010 WARNING: The author makes no guarantees and holds no responsibility for 
00011 any damage, injury or loss that may result from the use of this source 
00012 code. USE IT AT YOUR OWN RISK.
00013 
00014 Contact the author:
00015         by e-mail : rafael AT jannone DOT org
00016         homepage  : http://jannone.org/gfxlib
00017         ICQ UIN   : 10115284
00018 
00019 =========================================================================*/
00020 
00021 #include <stdio.h>
00022 #include "gfx.h"
00023 
00024 main() {
00025         // prepare for the lamest example ever :)
00026         // at least is very simple and self-explained
00027 
00028         printf("initializing psg\n");
00029 
00030         psg_init();
00031 
00032         printf("sound output\n");
00033 
00034         // psgT transforms a frequency (in Hertz) to a suitable period value for PSG
00035 
00036         psg_channels(chanAll, chanNone); // set all channels to tone generation
00037 
00038         // the following frequencies are based on the 440 Hz (central A tone) tunning
00039         psg_tone(0, psgT(130.8)); // produce a C tone on the first channel
00040         psg_tone(1, psgT(164.8)); // produce a E tone on the second channel
00041         psg_tone(2, psgT(195.9)); // produce a G tone on the third channel
00042 
00043         psg_envelope(envUH, psgT(10), chanAll); // set a raising volume envelope on all channels
00044 
00045         printf("press spacebar to stop\n");
00046 
00047         while (!get_trigger(0)) {}
00048 
00049         psg_envelope(envD, psgT(10), chanAll); // set a fading volume envelope on all channels
00050 }

Generated on Thu Mar 3 19:55:01 2005 for GFX lib by  doxygen 1.4.1