34 lines
1.3 KiB
C
34 lines
1.3 KiB
C
#pragma once
|
|
|
|
#include "Arduino.h"
|
|
#include "board.h"
|
|
|
|
#define SAMPLERATE_HZ 44100 // The sample rate of the audio. Higher sample rates have better fidelity,
|
|
// but these tones are so simple it won't make a difference. 44.1khz is
|
|
// standard CD quality sound.
|
|
|
|
#define AMPLITUDE ((1<<29)-1) // Set the amplitude of generated waveforms. This controls how loud
|
|
// the signals are, and can be any value from 0 to 2**31 - 1. Start with
|
|
// a low value to prevent damaging speakers!
|
|
|
|
#define WAV_SIZE 256 // The size of each generated waveform. The larger the size the higher
|
|
// quality the signal. A size of 256 is more than enough for these simple
|
|
// waveforms.
|
|
|
|
|
|
// Define the frequency of music notes (from http://www.phy.mtu.edu/~suits/notefreqs.html):
|
|
#define C4_HZ 261.63
|
|
#define D4_HZ 293.66
|
|
#define E4_HZ 329.63
|
|
#define F4_HZ 349.23
|
|
#define G4_HZ 392.00
|
|
#define A4_HZ 440.00
|
|
#define B4_HZ 493.88
|
|
|
|
// Define a C-major scale to play all the notes up and down.
|
|
float scale[] = { C4_HZ, D4_HZ, E4_HZ, F4_HZ, G4_HZ, A4_HZ, B4_HZ, A4_HZ, G4_HZ, F4_HZ, E4_HZ, D4_HZ, C4_HZ };
|
|
|
|
|
|
void initAudio(void);
|
|
void handleAudio(void);
|