aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/Source/c_sound.iom
blob: ec12076c2a3ad432af65d51b4727106a49b48de3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//
// Programmer      
//
// Date init       14.12.2004
//
// Reviser         $Author:: Dkandlun                                        $
//
// Revision date   $Date:: 14-11-07 12:40                                    $
//
// Filename        $Workfile:: c_sound.iom                                   $
//
// Version         $Revision:: 1                                             $
//
// Archive         $Archive:: /LMS2006/Sys01/Main_V02/Firmware/Source/c_soun $
//
// Platform        C
//

#ifndef   CSOUND_IOM
#define   CSOUND_IOM

#define   pMapSound ((IOMAPSOUND*)(pHeaders[ENTRY_SOUND]->pIOMap))  


/* HOW TO

Start a sound file            strcpy((char*)pMapSound->SoundFilename,"xxxxxxx.rso");
                              pMapSound->Volume   =  IOMapUi.Volume;
                              pMapSound->Mode     =  SOUND_ONCE;
                              pMapSound->Flags   |=  SOUND_UPDATE;


Start and loop a sound file   strcpy((char*)pMapSound->SoundFilename,"xxxxxxx.rso");
                              pMapSound->Volume   =  IOMapUi.Volume;
                              pMapSound->Mode     =  SOUND_LOOP;
                              pMapSound->Flags   |=  SOUND_UPDATE;


Start a tone                  pMapSound->Freq     =  440;
                              pMapSound->Duration =  1000;
                              pMapSound->Volume   =  IOMapUi.Volume;
                              pMapSound->Mode     =  SOUND_TONE;
                              pMapSound->Flags   |=  SOUND_UPDATE;


Start and loop a tone         pMapSound->Freq     =  440;
                              pMapSound->Duration =  1000;
                              pMapSound->Volume   =  IOMapUi.Volume;
                              pMapSound->Mode     =  SOUND_TONE | SOUND_LOOP;
                              pMapSound->Flags   |=  SOUND_UPDATE;



Test for sound finished       if (!(pMapSound->Flags & (SOUND_RUNNING | SOUND_UPDATE)))
                              {
                                // FINISHED
                              }
                              
                              
Abort sound or tone           pMapSound->State    =  SOUND_STOP;


**** Start always abort running sound or tone ****



*/

// Constants related to Flags
enum
{
  SOUND_UPDATE  = 0x01,                       // W  - Make changes take effect
  SOUND_RUNNING = 0x02                        // R  - Processing tone or file
};

// Constants related to State
enum
{
  SOUND_IDLE    = 0x00,                       // R  - Idle, ready for start sound (SOUND_UPDATE)
  SOUND_BUSY    = 0x02,                       // R  - Processing file of sound/melody data
  SOUND_FREQ    = 0x03,                       // R  - Processing play tone request
  SOUND_STOP    = 0x04                        // W  - Stop sound imedately and close hardware
};

// Constants related to Mode
enum
{
  SOUND_ONCE    = 0x00,                       // W  - Only play file once
  SOUND_LOOP    = 0x01,                       // W  - Play file until writing "SOUND_STOP" into "State" or new "update"
  SOUND_TONE    = 0x02                        // W  - Play tone specified in Freq for Duration ms
};

typedef   struct                              
{
  UWORD   Freq;                               // RW - Tone frequency [Hz]
  UWORD   Duration;                           // RW - Tone duration  [mS]
  UWORD   SampleRate;                         // RW - Sound file sample rate [2000..16000]
  UBYTE   SoundFilename[FILENAME_LENGTH + 1]; // RW - Sound/melody filename 
  UBYTE   Flags;                              // RW - Play flag  - descripted above
  UBYTE   State;                              // RW - Play state - descriped above
  UBYTE   Mode;                               // RW - Play mode  - descriped above
  UBYTE   Volume;                             // RW - Sound/melody volume [0..4] 0 = off
}IOMAPSOUND;


#endif