sound fine

This commit is contained in:
2024-10-03 02:37:05 +03:00
parent 0e845d9ebd
commit dd34d1bbb1
8 changed files with 326 additions and 158 deletions

View File

@ -14,6 +14,8 @@
#define SOUND_TIMER TIM4
#define SOUND_TIMER_RCC RCC_APB1ENR_TIM4EN
extern uint32_t bpm;
// Define the Note structure
typedef struct {
uint32_t frequency; // Frequency in Hz
@ -158,7 +160,13 @@ void sound_init(void);
void sound_set_bpm(uint32_t bpm);
void sound_play_note(Note_t note, uint8_t channel);
void sound_play_melody(Note_t* melody, uint32_t size, uint8_t channel, uint32_t repeat_count);
void sound_play_melody(Note_t* melody, uint32_t size, uint8_t channel, uint32_t repeat_count);
void sound_tick(void);
uint16_t get_array_size(Note_t *array);
Note_t sound_create_note(MusicalNote_t note, NoteDuration_t duration, uint8_t duty_cycle);
#define CREATE_NOTE(note, dur, duty) \
((Note_t){ .frequency = note, .duration = dur, .duty_cycle = duty })
#endif /* INC_SOUND_H_ */