dipl/code/textadv/src/sound.c
Tyrolyean 7bd98812f9
Added more and more stuff for dipl
Signed-off-by: Tyrolyean <tyrolyean@tyrolyean.net>
2020-03-15 01:28:01 +01:00

61 lines
1.6 KiB
C

/* Copyright © 2020 tyrolyean
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "sound.h"
#include "sound.h"
#include "dac.h"
#include <avr/pgmspace.h>
#include <stddef.h>
const struct tone_t lonely_road[] PROGMEM =
{
{DAC_MODE_SQUARE, -10,500},
{DAC_MODE_SQUARE, -9,500},
{DAC_MODE_SQUARE, -8,500},
{DAC_MODE_SQUARE, -7,500},
{DAC_MODE_SQUARE, -6,500},
{DAC_MODE_SQUARE, -5,500},
{DAC_MODE_SQUARE, -2,500},
{DAC_MODE_SQUARE, -2,500},
{DAC_MODE_SQUARE, -2,500},
{DAC_MODE_SILENT, 0, 0},
};
const struct tone_t **current_track = NULL;
void update_sound(){
static uint16_t audio_time = 0;
static size_t tone_pointer = 0x00;
audio_time++;
if(!(audio_time >=
pgm_read_word(&(*current_track)[tone_pointer].length))){
tone_pointer++;
if(pgm_read_word(&(*current_track)[tone_pointer].length) == 0){
tone_pointer = 0;
}
dac_mode = pgm_read_word(
&(*current_track)[tone_pointer].waveform);
dac_frequency_deviation = pgm_read_word(
&(*current_track)[tone_pointer].frequency_deviation);
}
return;
}