From 374045d1f8a5c55301e453d3977f00bdc122fe5c Mon Sep 17 00:00:00 2001 From: Reiner Herrmann Date: Fri, 10 Feb 2012 18:17:39 +0100 Subject: enable phonetic and reciting mode --- Makefile | 2 +- sam.c | 20 +++++++++++++++++--- sam.h | 3 ++- sam_player.c | 2 +- wave.h | 13 ------------- wave_linux.c | 7 +------ 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 0c2c47a..0ad24dd 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ STRIP = strip CC = gcc -CFLAGS = -D__USE_INLINE__ -O3 -ffast-math -finline-functions -funroll-loops -fstrict-aliasing -Wall -I$(SRC)c64 +CFLAGS = -D__USE_INLINE__ -O3 -ffast-math -funroll-loops -Wall -Ic64 LDFLAGS = -lsndfile TARGET = sam_player diff --git a/sam.c b/sam.c index c921c48..ec02fda 100644 --- a/sam.c +++ b/sam.c @@ -37,11 +37,11 @@ void sam_init(void) run_to(0xe5cd, 0xe5d5); feed("LOAD\"SAM.PRG\",1,1\r RUN\rH"); run_to(0xe5cd, 0xe5d5); - feed("]RE\r"); - run_to(0xe5cd, 0xe5d5); + //feed("]RE\r"); + //run_to(0xe5cd, 0xe5d5); } -void sam_say(const char *text, unsigned int frequency, unsigned char *wave_buf, unsigned int *wave_len_ref) +static void sam_say(const char *text, unsigned int frequency, unsigned char *wave_buf, unsigned int *wave_len_ref) { feed("SAY\""); feed(text); @@ -51,3 +51,17 @@ void sam_say(const char *text, unsigned int frequency, unsigned char *wave_buf, *wave_len_ref = stop_record(); } +void sam_recite(const char *text, unsigned int frequency, unsigned char *wave_buf, unsigned int *wave_len_ref) +{ + feed("]RECITER\r"); + run_to(0xe5cd, 0xe5d5); + sam_say(text, frequency, wave_buf, wave_len_ref); +} + +void sam_phonetic(const char *text, unsigned int frequency, unsigned char *wave_buf, unsigned int *wave_len_ref) +{ + feed("]SAM\r"); + run_to(0xe5cd, 0xe5d5); + sam_say(text, frequency, wave_buf, wave_len_ref); +} + diff --git a/sam.h b/sam.h index 4379978..4b7bad8 100644 --- a/sam.h +++ b/sam.h @@ -6,7 +6,8 @@ #define __SAM_H__ 1 void sam_init(void); -void sam_say(const char *text, unsigned int frequency, unsigned char *wave_buf, unsigned int *wave_len_ref); +void sam_recite(const char *text, unsigned int frequency, unsigned char *wave_buf, unsigned int *wave_len_ref); +void sam_phonetic(const char *text, unsigned int frequency, unsigned char *wave_buf, unsigned int *wave_len_ref); #endif diff --git a/sam_player.c b/sam_player.c index 43baf40..04207b2 100644 --- a/sam_player.c +++ b/sam_player.c @@ -34,7 +34,7 @@ int main(int argc, char **argv) *p = '\0'; sam_init(); wave_length = sizeof(wave_buffer); - sam_say(buf, wave.samples_per_sec, wave_buffer, &wave_length); + sam_recite(buf, wave.samples_per_sec, wave_buffer, &wave_length); if(wave_length > 0) { if(wave_length > sizeof(wave_buffer)) diff --git a/wave.h b/wave.h index a28ff4e..3798996 100644 --- a/wave.h +++ b/wave.h @@ -3,17 +3,6 @@ #ifndef __WAVE_H__ #define __WAVE_H__ 1 -#define WAVE_ERR_NONE 0 -#define WAVE_ERR_UNKNOWN_ERROR -1 -#define WAVE_ERR_RESOURCE_UNAVAILABLE -2 -#define WAVE_ERR_BAD_DEVICE_ID -3 -#define WAVE_ERR_DEVICE_DRIVER_UNAVAILABLE -4 -#define WAVE_ERR_OUT_OF_MEMORY -5 -#define WAVE_ERR_INVALID_WAVE -6 -#define WAVE_ERR_CANNOT_PLAY -7 -#define WAVE_ERR_INVALID_HANDLE -8 -#define WAVE_ERR_STILL_PLAYING -9 - typedef struct __wave { int channels; // audio channels, mono, stereo, etc... @@ -26,6 +15,4 @@ typedef struct __wave int wave_out(wave_t *wave); -const char *wave_err_to_str(int err); - #endif diff --git a/wave_linux.c b/wave_linux.c index 6d04fb7..f960a9b 100644 --- a/wave_linux.c +++ b/wave_linux.c @@ -1,6 +1,5 @@ #include "wave.h" -#include #include int wave_out(wave_t *wave) @@ -16,11 +15,7 @@ int wave_out(wave_t *wave) sf_write_raw(out, wave->frame_data, wave->frame_size); sf_close(out); - printf("channels: %d, samples_per_sec: %d, bits_per_sample: %d, frame_size: %d, frame_count: %d\n", wave->channels, wave->samples_per_sec, wave->bits_per_sample, wave->frame_size, wave->frame_count); + //printf("channels: %d, samples_per_sec: %d, bits_per_sample: %d, frame_size: %d, frame_count: %d\n", wave->channels, wave->samples_per_sec, wave->bits_per_sample, wave->frame_size, wave->frame_count); return 0; } -const char *wave_err_to_str(int err) -{ - return "unknown error"; -} -- cgit v1.2.3