PicoVGA  1.0-cmake
VGA/TV display on Raspberry Pico
pwmsnd.h
Go to the documentation of this file.
1 
8 #ifndef _PWMSND_H
9 #define _PWMSND_H
10 
11 #define PWMSND_GPIO 19 // PWM output GPIO pin (0..29)
12 #define PWMSND_SLICE ((PWMSND_GPIO>>1)&7) // PWM slice index (=1)
13 #define PWMSND_CHAN (PWMSND_GPIO&1) // PWM channel index (=1)
14 
15 #define SOUNDRATE 22050 // sound rate [Hz]
16 #define PWMSND_TOP 255 // PRM top (period = PWMSND_TOP + 1 = 256)
17 #define PWMSND_CLOCK (SOUNDRATE*(PWMSND_TOP+1)) // PWM clock (= 22050*256 = 5644800)
18 
19 #define SNDFRAC 10 // number of fraction bits
20 #define SNDINT (1<<SNDFRAC) // integer part of sound fraction
21 
22 // current sound
23 extern const u8* CurSound; // current playing sound
24 extern volatile int SoundCnt; // counter of current playing sound (<=0 no sound)
25 extern int SoundInc; // pointer increment
26 extern volatile int SoundAcc; // pointer accumulator
27 extern const u8* NextSound; // next sound to play repeated sound
28 extern int NextSoundCnt; // counter of next sound (0=no repeated sound)
29 
50 void PWMSndInit();
51 
62 void PlaySound(const u8* snd, int len, Bool rep = False, float speed = 1.0f);
63 
69 void StopSound();
70 
71 // update sound speed (1=normal speed)
77 void SpeedSound(float speed);
78 
82 Bool PlayingSound();
83 
90 void SetNextSound(const u8* snd, int len);
91 
93 
94 #endif // _PWMSND_H
PlayingSound
Bool PlayingSound()
Check if playing sound.
Definition: pwmsnd.cpp:138
SetNextSound
void SetNextSound(const u8 *snd, int len)
Set the next sound to play.
Definition: pwmsnd.cpp:144
SpeedSound
void SpeedSound(float speed)
Update sound speed.
Definition: pwmsnd.cpp:132
PlaySound
void PlaySound(const u8 *snd, int len, Bool rep=False, float speed=1.0f)
Output PWM sound.
Definition: pwmsnd.cpp:97
StopSound
void StopSound()
stop playing sound
Definition: pwmsnd.cpp:124
PWMSndInit
void PWMSndInit()
Initialize PWM sound output.
Definition: pwmsnd.cpp:65