From 8dee01b44f44513972b7de651fab5f0c3326e0eb Mon Sep 17 00:00:00 2001 From: jean-marcharvengt Date: Sat, 17 Oct 2020 16:06:14 +0200 Subject: [PATCH] add experimental VGAT4 sound support --- MCUME_teensy/teensy5200/AudioPlaySystem.cpp | 50 ++++++------- MCUME_teensy/teensy5200/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensy5200/pokeysnd.c | 2 +- MCUME_teensy/teensy5200/teensy5200.ino | 19 +++-- MCUME_teensy/{ => teensy64}/.DS_Store | Bin 6148 -> 6148 bytes MCUME_teensy/teensy64/AudioPlaySystem.cpp | 47 ++++++------ MCUME_teensy/teensy64/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensy64/platform_config.h | 2 +- MCUME_teensy/teensy64/teensy64.ino | 18 +++-- MCUME_teensy/teensy800/AudioPlaySystem.cpp | 51 +++++++------ MCUME_teensy/teensy800/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensy800/platform_config.h | 2 +- MCUME_teensy/teensy800/pokeysnd.c | 2 +- MCUME_teensy/teensy800/teensy800.ino | 17 ++--- MCUME_teensy/teensy81/AudioPlaySystem.cpp | 47 ++++++------ MCUME_teensy/teensy81/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensy81/platform_config.h | 2 +- MCUME_teensy/teensy81/teensy81.ino | 20 +++-- MCUME_teensy/teensycolem/.DS_Store | Bin 0 -> 6148 bytes MCUME_teensy/teensycolem/AudioPlaySystem.cpp | 51 +++++++------ MCUME_teensy/teensycolem/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensycolem/Colem.c | 2 +- MCUME_teensy/teensycolem/platform_config.h | 2 +- MCUME_teensy/teensycolem/teensycolem.ino | 18 ++--- MCUME_teensy/teensygen/AudioPlaySystem.cpp | 69 ++++++++--------- MCUME_teensy/teensygen/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensygen/platform_config.h | 2 +- MCUME_teensy/teensygen/teensygen.ino | 22 +++--- MCUME_teensy/teensygnuboy/AudioPlaySystem.cpp | 69 ++++++++--------- MCUME_teensy/teensygnuboy/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensygnuboy/teensygnuboy.ino | 18 +++-- MCUME_teensy/teensymsx/AudioPlaySystem.cpp | 67 +++++++++-------- MCUME_teensy/teensymsx/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensymsx/teensymsx.ino | 19 +++-- .../teensynofrendo/AudioPlaySystem.cpp | 47 ++++++------ MCUME_teensy/teensynofrendo/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensynofrendo/platform_config.h | 2 +- .../teensynofrendo/teensynofrendo.ino | 17 ++--- MCUME_teensy/teensyo2em/AudioPlaySystem.cpp | 51 +++++++------ MCUME_teensy/teensyo2em/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensyo2em/teensyo2em.ino | 17 ++--- MCUME_teensy/teensypce/AudioPlaySystem.cpp | 69 ++++++++--------- MCUME_teensy/teensypce/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensypce/platform_config.h | 2 +- MCUME_teensy/teensypce/teensypce.ino | 17 ++--- MCUME_teensy/teensysms/AudioPlaySystem.cpp | 69 ++++++++--------- MCUME_teensy/teensysms/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensysms/platform_config.h | 2 +- MCUME_teensy/teensysms/teensysms.ino | 18 +++-- MCUME_teensy/teensyspeccy/.DS_Store | Bin 0 -> 6148 bytes MCUME_teensy/teensyspeccy/AudioPlaySystem.cpp | 51 +++++++------ MCUME_teensy/teensyspeccy/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensyspeccy/platform_config.h | 2 +- MCUME_teensy/teensyspeccy/teensyspeccy.ino | 17 ++--- MCUME_teensy/teensyvcs/AudioPlaySystem.cpp | 51 +++++++------ MCUME_teensy/teensyvcs/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensyvcs/teensyvcs.ino | 18 ++--- .../teensyvectrex/AudioPlaySystem.cpp | 51 +++++++------ MCUME_teensy/teensyvectrex/AudioPlaySystem.h | 42 +++++++++-- MCUME_teensy/teensyvectrex/teensyvectrex.ino | 17 +++-- .../teensyuae41/AudioPlaySystem.cpp | 70 +++++++++--------- MCUME_teensy41/teensyuae41/AudioPlaySystem.h | 41 ++++++++-- MCUME_teensy41/teensyuae41/emuapi.cpp | 4 +- MCUME_teensy41/teensyuae41/platform_config.h | 3 +- MCUME_teensy41/teensyuae41/teensyuae41.ino | 23 ++++-- MCUME_teensy41/teensyuae41/uae.cpp | 4 + MCUME_teensy41/teensyuae41/vga_t_dma.h | 14 ++-- 67 files changed, 1173 insertions(+), 752 deletions(-) rename MCUME_teensy/{ => teensy64}/.DS_Store (81%) create mode 100644 MCUME_teensy/teensycolem/.DS_Store create mode 100644 MCUME_teensy/teensyspeccy/.DS_Store diff --git a/MCUME_teensy/teensy5200/AudioPlaySystem.cpp b/MCUME_teensy/teensy5200/AudioPlaySystem.cpp index c5d44a5..b03ddd9 100644 --- a/MCUME_teensy/teensy5200/AudioPlaySystem.cpp +++ b/MCUME_teensy/teensy5200/AudioPlaySystem.cpp @@ -68,8 +68,6 @@ static Channel chan[6] = { volatile bool playing = false; - - static void snd_Reset(void) { #ifndef CUSTOM_SND @@ -91,21 +89,21 @@ static void snd_Reset(void) #ifdef CUSTOM_SND extern "C" { -void POKEYSND_Process(void *sndbuffer, int sndn); +void SND_Process(void *sndbuffer, int sndn); } #endif -static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND - POKEYSND_Process((void*)stream, len); +#ifdef CUSTOM_SND + SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -135,14 +133,14 @@ static void snd_Mixer(short * stream, int len ) void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - //setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } @@ -151,14 +149,14 @@ void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } bool AudioPlaySystem::isPlaying(void) @@ -166,22 +164,24 @@ bool AudioPlaySystem::isPlaying(void) return playing; } +#ifndef HAS_T4_VGA void AudioPlaySystem::update(void) { - audio_block_t *block; + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND diff --git a/MCUME_teensy/teensy5200/AudioPlaySystem.h b/MCUME_teensy/teensy5200/AudioPlaySystem.h index 0333adb..db34b9d 100644 --- a/MCUME_teensy/teensy5200/AudioPlaySystem.h +++ b/MCUME_teensy/teensy5200/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensy5200/pokeysnd.c b/MCUME_teensy/teensy5200/pokeysnd.c index c3d66e5..4b71ef2 100644 --- a/MCUME_teensy/teensy5200/pokeysnd.c +++ b/MCUME_teensy/teensy5200/pokeysnd.c @@ -362,7 +362,7 @@ void POKEYSND_SetMzQuality(int quality) /* specially for win32, perhaps not need mz_quality = quality; } -void POKEYSND_Process(void *sndbuffer, int sndn) +void SND_Process(void *sndbuffer, int sndn) { POKEYSND_Process_ptr(sndbuffer, sndn); #if defined(PBI_XLD) || defined (VOICEBOX) diff --git a/MCUME_teensy/teensy5200/teensy5200.ino b/MCUME_teensy/teensy5200/teensy5200.ino index 8a7a02a..335fd0c 100644 --- a/MCUME_teensy/teensy5200/teensy5200.ino +++ b/MCUME_teensy/teensy5200/teensy5200.ino @@ -202,7 +202,7 @@ void * emu_LineBuffer(int line) void setup() { #ifdef HAS_T4_VGA - tft.begin(VGA_MODE_352x240); + tft.begin(VGA_MODE_320x240); // NVIC_SET_PRIORITY(IRQ_QTIMER3, 0); #else tft.begin(); @@ -273,32 +273,31 @@ void loop(void) #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); #ifdef HAS_T4_VGA - sgtl5000_1.enable(); - sgtl5000_1.volume(0.6); + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); #endif - AudioMemory(16); mymixer.start(); } diff --git a/MCUME_teensy/.DS_Store b/MCUME_teensy/teensy64/.DS_Store similarity index 81% rename from MCUME_teensy/.DS_Store rename to MCUME_teensy/teensy64/.DS_Store index e864d24d14013b4bfee19f2c9f0702d7cb8cd79a..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 100644 GIT binary patch delta 70 zcmZoMXfc=|#>AjHu~2NHo+1YW5HK<@2yAv_KE|>+fcX{EW_AvK4xj>{$am(+{342+ UKzW7)kiy9(Jj$D6L{=~Z044qo@Bjb+ delta 392 zcmZoMXfc=|#>B)qF;Q%yo}wr-0|Nsi1A_nqLoq`og9U>D5SwjGT+UbzlHp<~VMqnS zJY?CV^5TM|octu9{HdgZoXp}91B2^~Ow25-Z0sByTpV1yT(Q9!`Q^bSi6y1QPKia) zAYMRXNk$Ts9g?4)17{~Dg=MCe#|wx!=jW9qX6B_9fi>4>rlbPZ#Dr(&rR0}8<(KBA z6oU;4hDdO5aB^_Q3rJR18yQ;aC>WVr*6Ju!8yc9H>nNBT7}wTva)_%M+IlABR#sKl z)Yi=cIu{5Sfu02eekcv2W&;_>-Zh7ZMpn0TCJ mvVjQ8W^N8{4q!NMO#IF~nO{Val?kX> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -135,14 +133,14 @@ static void snd_Mixer(short * stream, int len ) void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - //setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } @@ -151,14 +149,14 @@ void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } bool AudioPlaySystem::isPlaying(void) @@ -166,22 +164,24 @@ bool AudioPlaySystem::isPlaying(void) return playing; } +#ifndef HAS_T4_VGA void AudioPlaySystem::update(void) { - audio_block_t *block; + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND @@ -195,4 +195,3 @@ void AudioPlaySystem::sound(int C, int F, int V) { void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensy64/AudioPlaySystem.h b/MCUME_teensy/teensy64/AudioPlaySystem.h index 0333adb..7b775ae 100644 --- a/MCUME_teensy/teensy64/AudioPlaySystem.h +++ b/MCUME_teensy/teensy64/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +//#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensy64/platform_config.h b/MCUME_teensy/teensy64/platform_config.h index 7a08489..d169431 100644 --- a/MCUME_teensy/teensy64/platform_config.h +++ b/MCUME_teensy/teensy64/platform_config.h @@ -7,7 +7,7 @@ //#define INVX 1 //#define INVY 1 -//#define HAS_SND 1 +#define HAS_SND 1 #define HAS_USBKEY 1 //#define HAS_I2CKBD 1 diff --git a/MCUME_teensy/teensy64/teensy64.ino b/MCUME_teensy/teensy64/teensy64.ino index e8411a2..08ad92b 100644 --- a/MCUME_teensy/teensy64/teensy64.ino +++ b/MCUME_teensy/teensy64/teensy64.ino @@ -275,31 +275,33 @@ void loop(void) } } - #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); - AudioMemory(16); +#ifdef HAS_T4_VGA + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); +#endif mymixer.start(); } diff --git a/MCUME_teensy/teensy800/AudioPlaySystem.cpp b/MCUME_teensy/teensy800/AudioPlaySystem.cpp index e6b82e1..b03ddd9 100644 --- a/MCUME_teensy/teensy800/AudioPlaySystem.cpp +++ b/MCUME_teensy/teensy800/AudioPlaySystem.cpp @@ -68,8 +68,6 @@ static Channel chan[6] = { volatile bool playing = false; - - static void snd_Reset(void) { #ifndef CUSTOM_SND @@ -91,21 +89,21 @@ static void snd_Reset(void) #ifdef CUSTOM_SND extern "C" { -void POKEYSND_Process(void *sndbuffer, int sndn); +void SND_Process(void *sndbuffer, int sndn); } #endif -static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND - POKEYSND_Process((void*)stream, len); +#ifdef CUSTOM_SND + SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -135,14 +133,14 @@ static void snd_Mixer(short * stream, int len ) void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - //setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } @@ -151,14 +149,14 @@ void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } bool AudioPlaySystem::isPlaying(void) @@ -166,22 +164,24 @@ bool AudioPlaySystem::isPlaying(void) return playing; } +#ifndef HAS_T4_VGA void AudioPlaySystem::update(void) { - audio_block_t *block; + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND @@ -195,4 +195,3 @@ void AudioPlaySystem::sound(int C, int F, int V) { void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensy800/AudioPlaySystem.h b/MCUME_teensy/teensy800/AudioPlaySystem.h index 0333adb..7b775ae 100644 --- a/MCUME_teensy/teensy800/AudioPlaySystem.h +++ b/MCUME_teensy/teensy800/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +//#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensy800/platform_config.h b/MCUME_teensy/teensy800/platform_config.h index 829219c..5b2458c 100644 --- a/MCUME_teensy/teensy800/platform_config.h +++ b/MCUME_teensy/teensy800/platform_config.h @@ -4,7 +4,7 @@ //#define OLD_LAYOUT 1 #define HAS_T4_VGA 1 -//#define HAS_SND 1 +#define HAS_SND 1 //#define INVX 1 //#define INVY 1 #define HAS_USBKEY 1 diff --git a/MCUME_teensy/teensy800/pokeysnd.c b/MCUME_teensy/teensy800/pokeysnd.c index 0c0a7f5..7545f7a 100644 --- a/MCUME_teensy/teensy800/pokeysnd.c +++ b/MCUME_teensy/teensy800/pokeysnd.c @@ -362,7 +362,7 @@ void POKEYSND_SetMzQuality(int quality) /* specially for win32, perhaps not need mz_quality = quality; } -void POKEYSND_Process(void *sndbuffer, int sndn) +void SND_Process(void *sndbuffer, int sndn) { POKEYSND_Process_ptr(sndbuffer, sndn); #if defined(PBI_XLD) || defined (VOICEBOX) diff --git a/MCUME_teensy/teensy800/teensy800.ino b/MCUME_teensy/teensy800/teensy800.ino index 3122905..75becca 100644 --- a/MCUME_teensy/teensy800/teensy800.ino +++ b/MCUME_teensy/teensy800/teensy800.ino @@ -202,7 +202,7 @@ void * emu_LineBuffer(int line) void setup() { #ifdef HAS_T4_VGA - tft.begin(VGA_MODE_352x240); + tft.begin(VGA_MODE_320x240); // NVIC_SET_PRIORITY(IRQ_QTIMER3, 255); #else tft.begin(); @@ -269,36 +269,33 @@ void loop(void) } } - - #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); #ifdef HAS_T4_VGA + tft.begin_audio(256, mymixer.snd_Mixer); // sgtl5000_1.enable(); // sgtl5000_1.volume(0.6); #endif - AudioMemory(16); mymixer.start(); } diff --git a/MCUME_teensy/teensy81/AudioPlaySystem.cpp b/MCUME_teensy/teensy81/AudioPlaySystem.cpp index 8fea18d..b03ddd9 100644 --- a/MCUME_teensy/teensy81/AudioPlaySystem.cpp +++ b/MCUME_teensy/teensy81/AudioPlaySystem.cpp @@ -68,8 +68,6 @@ static Channel chan[6] = { volatile bool playing = false; - - static void snd_Reset(void) { #ifndef CUSTOM_SND @@ -95,17 +93,17 @@ void SND_Process(void *sndbuffer, int sndn); } #endif -static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND +#ifdef CUSTOM_SND SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -135,14 +133,14 @@ static void snd_Mixer(short * stream, int len ) void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - //setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } @@ -151,14 +149,14 @@ void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } bool AudioPlaySystem::isPlaying(void) @@ -166,22 +164,24 @@ bool AudioPlaySystem::isPlaying(void) return playing; } +#ifndef HAS_T4_VGA void AudioPlaySystem::update(void) { - audio_block_t *block; + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND @@ -195,4 +195,3 @@ void AudioPlaySystem::sound(int C, int F, int V) { void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensy81/AudioPlaySystem.h b/MCUME_teensy/teensy81/AudioPlaySystem.h index 0333adb..7b775ae 100644 --- a/MCUME_teensy/teensy81/AudioPlaySystem.h +++ b/MCUME_teensy/teensy81/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +//#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensy81/platform_config.h b/MCUME_teensy/teensy81/platform_config.h index 20c3d94..e913727 100644 --- a/MCUME_teensy/teensy81/platform_config.h +++ b/MCUME_teensy/teensy81/platform_config.h @@ -4,7 +4,7 @@ //#define OLD_LAYOUT 1 #define HAS_T4_VGA 1 -//#define HAS_SND 1 +#define HAS_SND 1 //#define INVX 1 //#define INVY 1 #define HAS_USBKEY 1 diff --git a/MCUME_teensy/teensy81/teensy81.ino b/MCUME_teensy/teensy81/teensy81.ino index ebc839e..ee7d762 100644 --- a/MCUME_teensy/teensy81/teensy81.ino +++ b/MCUME_teensy/teensy81/teensy81.ino @@ -203,7 +203,7 @@ void * emu_LineBuffer(int line) void setup() { #ifdef HAS_T4_VGA - tft.begin(VGA_MODE_352x240); + tft.begin(VGA_MODE_320x240); // NVIC_SET_PRIORITY(IRQ_QTIMER3, 0); #else tft.begin(); @@ -271,35 +271,33 @@ void loop(void) } - #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); #ifdef HAS_T4_VGA - sgtl5000_1.enable(); - sgtl5000_1.volume(0.6); + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); #endif - AudioMemory(16); mymixer.start(); } diff --git a/MCUME_teensy/teensycolem/.DS_Store b/MCUME_teensy/teensycolem/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -135,14 +133,14 @@ static void snd_Mixer(short * stream, int len ) void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - //setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } @@ -151,14 +149,14 @@ void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } bool AudioPlaySystem::isPlaying(void) @@ -166,22 +164,24 @@ bool AudioPlaySystem::isPlaying(void) return playing; } +#ifndef HAS_T4_VGA void AudioPlaySystem::update(void) { - audio_block_t *block; + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND @@ -195,4 +195,3 @@ void AudioPlaySystem::sound(int C, int F, int V) { void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensycolem/AudioPlaySystem.h b/MCUME_teensy/teensycolem/AudioPlaySystem.h index 0333adb..7b775ae 100644 --- a/MCUME_teensy/teensycolem/AudioPlaySystem.h +++ b/MCUME_teensy/teensycolem/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +//#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensycolem/Colem.c b/MCUME_teensy/teensycolem/Colem.c index 1e58f7d..191c7c9 100644 --- a/MCUME_teensy/teensycolem/Colem.c +++ b/MCUME_teensy/teensycolem/Colem.c @@ -201,7 +201,7 @@ int coc_Start(char * Cartridge) snd_Reset(); #endif #ifdef SOUND_PRESENT - snd_Open(22050, 2, 4096/*16384*/,(void*)snd_Mixer); + snd_Open(44100/*22050*/, 2, 4096/*16384*/,(void*)snd_Mixer); #endif /* Initialize VDP registers */ diff --git a/MCUME_teensy/teensycolem/platform_config.h b/MCUME_teensy/teensycolem/platform_config.h index 56342dd..652427d 100644 --- a/MCUME_teensy/teensycolem/platform_config.h +++ b/MCUME_teensy/teensycolem/platform_config.h @@ -4,7 +4,7 @@ //#define OLD_LAYOUT 1 #define HAS_T4_VGA 1 -//#define HAS_SND 1 +#define HAS_SND 1 //#define INVX 1 //#define INVY 1 #define HAS_USBKEY 1 diff --git a/MCUME_teensy/teensycolem/teensycolem.ino b/MCUME_teensy/teensycolem/teensycolem.ino index f86a72a..c42e289 100644 --- a/MCUME_teensy/teensycolem/teensycolem.ino +++ b/MCUME_teensy/teensycolem/teensycolem.ino @@ -270,35 +270,33 @@ void loop(void) } - #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); #ifdef HAS_T4_VGA - sgtl5000_1.enable(); - sgtl5000_1.volume(0.6); + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); #endif - AudioMemory(16); mymixer.start(); } diff --git a/MCUME_teensy/teensygen/AudioPlaySystem.cpp b/MCUME_teensy/teensygen/AudioPlaySystem.cpp index cdcd71b..0d156b3 100644 --- a/MCUME_teensy/teensygen/AudioPlaySystem.cpp +++ b/MCUME_teensy/teensygen/AudioPlaySystem.cpp @@ -68,9 +68,7 @@ static Channel chan[6] = { volatile bool playing = false; - - -PROGMEM static void snd_Reset(void) +static void snd_Reset(void) { #ifndef CUSTOM_SND chan[0].vol = 0; @@ -90,20 +88,22 @@ PROGMEM static void snd_Reset(void) #ifdef CUSTOM_SND +//extern "C" { void SND_Process(void *sndbuffer, int sndn); +//} #endif -PROGMEM static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND +#ifdef CUSTOM_SND SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -131,57 +131,59 @@ PROGMEM static void snd_Mixer(short * stream, int len ) } } -PROGMEM void AudioPlaySystem::begin(void) +void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } -PROGMEM void AudioPlaySystem::start(void) +void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } -PROGMEM void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { +void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { } -PROGMEM void AudioPlaySystem::reset(void) +void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } -PROGMEM void AudioPlaySystem::stop(void) +void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } -PROGMEM bool AudioPlaySystem::isPlaying(void) +bool AudioPlaySystem::isPlaying(void) { return playing; } -PROGMEM void AudioPlaySystem::update(void) { - audio_block_t *block; +#ifndef HAS_T4_VGA +void AudioPlaySystem::update(void) { + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif -PROGMEM void AudioPlaySystem::sound(int C, int F, int V) { +void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND if (C < 6) { chan[C].vol = V; @@ -190,7 +192,6 @@ PROGMEM void AudioPlaySystem::sound(int C, int F, int V) { #endif } -PROGMEM void AudioPlaySystem::step(void) { +void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensygen/AudioPlaySystem.h b/MCUME_teensy/teensygen/AudioPlaySystem.h index 0333adb..db34b9d 100644 --- a/MCUME_teensy/teensygen/AudioPlaySystem.h +++ b/MCUME_teensy/teensygen/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensygen/platform_config.h b/MCUME_teensy/teensygen/platform_config.h index 6afc3f4..b098960 100644 --- a/MCUME_teensy/teensygen/platform_config.h +++ b/MCUME_teensy/teensygen/platform_config.h @@ -5,7 +5,7 @@ #define HAS_T41 1 #define HAS_T4_VGA 1 -//#define HAS_SND 1 +#define HAS_SND 1 //#define INVX 1 //#define INVY 1 #define HAS_USBKEY 1 diff --git a/MCUME_teensy/teensygen/teensygen.ino b/MCUME_teensy/teensygen/teensygen.ino index b6409ac..a86cb6e 100644 --- a/MCUME_teensy/teensygen/teensygen.ino +++ b/MCUME_teensy/teensygen/teensygen.ino @@ -210,6 +210,7 @@ void setup() { myTimer.begin(vblCount, 20000); //to run every 20ms } + // **************************************************** // the loop() method runs continuously // **************************************************** @@ -262,41 +263,38 @@ void loop(void) if ( (!virtualkeyboardIsActive()) || (vgaMode) ) { emu_Step(); uint16_t bClick = emu_DebounceLocalKeys(); - emu_Input(bClick); + emu_Input(bClick); } } } - - #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); #ifdef HAS_T4_VGA - sgtl5000_1.enable(); - sgtl5000_1.volume(0.6); + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); #endif - AudioMemory(16); mymixer.start(); } diff --git a/MCUME_teensy/teensygnuboy/AudioPlaySystem.cpp b/MCUME_teensy/teensygnuboy/AudioPlaySystem.cpp index cdcd71b..0d156b3 100644 --- a/MCUME_teensy/teensygnuboy/AudioPlaySystem.cpp +++ b/MCUME_teensy/teensygnuboy/AudioPlaySystem.cpp @@ -68,9 +68,7 @@ static Channel chan[6] = { volatile bool playing = false; - - -PROGMEM static void snd_Reset(void) +static void snd_Reset(void) { #ifndef CUSTOM_SND chan[0].vol = 0; @@ -90,20 +88,22 @@ PROGMEM static void snd_Reset(void) #ifdef CUSTOM_SND +//extern "C" { void SND_Process(void *sndbuffer, int sndn); +//} #endif -PROGMEM static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND +#ifdef CUSTOM_SND SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -131,57 +131,59 @@ PROGMEM static void snd_Mixer(short * stream, int len ) } } -PROGMEM void AudioPlaySystem::begin(void) +void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } -PROGMEM void AudioPlaySystem::start(void) +void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } -PROGMEM void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { +void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { } -PROGMEM void AudioPlaySystem::reset(void) +void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } -PROGMEM void AudioPlaySystem::stop(void) +void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } -PROGMEM bool AudioPlaySystem::isPlaying(void) +bool AudioPlaySystem::isPlaying(void) { return playing; } -PROGMEM void AudioPlaySystem::update(void) { - audio_block_t *block; +#ifndef HAS_T4_VGA +void AudioPlaySystem::update(void) { + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif -PROGMEM void AudioPlaySystem::sound(int C, int F, int V) { +void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND if (C < 6) { chan[C].vol = V; @@ -190,7 +192,6 @@ PROGMEM void AudioPlaySystem::sound(int C, int F, int V) { #endif } -PROGMEM void AudioPlaySystem::step(void) { +void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensygnuboy/AudioPlaySystem.h b/MCUME_teensy/teensygnuboy/AudioPlaySystem.h index 0333adb..7b775ae 100644 --- a/MCUME_teensy/teensygnuboy/AudioPlaySystem.h +++ b/MCUME_teensy/teensygnuboy/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +//#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensygnuboy/teensygnuboy.ino b/MCUME_teensy/teensygnuboy/teensygnuboy.ino index d8131a4..37232ed 100644 --- a/MCUME_teensy/teensygnuboy/teensygnuboy.ino +++ b/MCUME_teensy/teensygnuboy/teensygnuboy.ino @@ -277,31 +277,33 @@ void loop(void) } } - #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); - AudioMemory(16); +#ifdef HAS_T4_VGA + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); +#endif mymixer.start(); } diff --git a/MCUME_teensy/teensymsx/AudioPlaySystem.cpp b/MCUME_teensy/teensymsx/AudioPlaySystem.cpp index bafb186..b03ddd9 100644 --- a/MCUME_teensy/teensymsx/AudioPlaySystem.cpp +++ b/MCUME_teensy/teensymsx/AudioPlaySystem.cpp @@ -68,9 +68,7 @@ static Channel chan[6] = { volatile bool playing = false; - - -PROGMEM static void snd_Reset(void) +static void snd_Reset(void) { #ifndef CUSTOM_SND chan[0].vol = 0; @@ -95,17 +93,17 @@ void SND_Process(void *sndbuffer, int sndn); } #endif -PROGMEM static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND +#ifdef CUSTOM_SND SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -133,57 +131,59 @@ PROGMEM static void snd_Mixer(short * stream, int len ) } } -PROGMEM void AudioPlaySystem::begin(void) +void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } -PROGMEM void AudioPlaySystem::start(void) +void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } -PROGMEM void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { +void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { } -PROGMEM void AudioPlaySystem::reset(void) +void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } -PROGMEM void AudioPlaySystem::stop(void) +void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } -PROGMEM bool AudioPlaySystem::isPlaying(void) +bool AudioPlaySystem::isPlaying(void) { return playing; } -PROGMEM void AudioPlaySystem::update(void) { - audio_block_t *block; +#ifndef HAS_T4_VGA +void AudioPlaySystem::update(void) { + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif -PROGMEM void AudioPlaySystem::sound(int C, int F, int V) { +void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND if (C < 6) { chan[C].vol = V; @@ -192,7 +192,6 @@ PROGMEM void AudioPlaySystem::sound(int C, int F, int V) { #endif } -PROGMEM void AudioPlaySystem::step(void) { +void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensymsx/AudioPlaySystem.h b/MCUME_teensy/teensymsx/AudioPlaySystem.h index 0333adb..db34b9d 100644 --- a/MCUME_teensy/teensymsx/AudioPlaySystem.h +++ b/MCUME_teensy/teensymsx/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensymsx/teensymsx.ino b/MCUME_teensy/teensymsx/teensymsx.ino index b9f3668..95dbbbc 100644 --- a/MCUME_teensy/teensymsx/teensymsx.ino +++ b/MCUME_teensy/teensymsx/teensymsx.ino @@ -207,7 +207,7 @@ void setup() { #ifdef HAS_T4_VGA tft.begin(VGA_MODE_320x240); - NVIC_SET_PRIORITY(IRQ_QTIMER3, 0); + //NVIC_SET_PRIORITY(IRQ_QTIMER3, 0); #else tft.begin(); #endif @@ -282,28 +282,31 @@ void loop(void) #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); - AudioMemory(16); +#ifdef HAS_T4_VGA + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); +#endif mymixer.start(); } diff --git a/MCUME_teensy/teensynofrendo/AudioPlaySystem.cpp b/MCUME_teensy/teensynofrendo/AudioPlaySystem.cpp index 8fea18d..b03ddd9 100644 --- a/MCUME_teensy/teensynofrendo/AudioPlaySystem.cpp +++ b/MCUME_teensy/teensynofrendo/AudioPlaySystem.cpp @@ -68,8 +68,6 @@ static Channel chan[6] = { volatile bool playing = false; - - static void snd_Reset(void) { #ifndef CUSTOM_SND @@ -95,17 +93,17 @@ void SND_Process(void *sndbuffer, int sndn); } #endif -static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND +#ifdef CUSTOM_SND SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -135,14 +133,14 @@ static void snd_Mixer(short * stream, int len ) void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - //setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } @@ -151,14 +149,14 @@ void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } bool AudioPlaySystem::isPlaying(void) @@ -166,22 +164,24 @@ bool AudioPlaySystem::isPlaying(void) return playing; } +#ifndef HAS_T4_VGA void AudioPlaySystem::update(void) { - audio_block_t *block; + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND @@ -195,4 +195,3 @@ void AudioPlaySystem::sound(int C, int F, int V) { void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensynofrendo/AudioPlaySystem.h b/MCUME_teensy/teensynofrendo/AudioPlaySystem.h index 0333adb..7b775ae 100644 --- a/MCUME_teensy/teensynofrendo/AudioPlaySystem.h +++ b/MCUME_teensy/teensynofrendo/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +//#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensynofrendo/platform_config.h b/MCUME_teensy/teensynofrendo/platform_config.h index 56342dd..652427d 100644 --- a/MCUME_teensy/teensynofrendo/platform_config.h +++ b/MCUME_teensy/teensynofrendo/platform_config.h @@ -4,7 +4,7 @@ //#define OLD_LAYOUT 1 #define HAS_T4_VGA 1 -//#define HAS_SND 1 +#define HAS_SND 1 //#define INVX 1 //#define INVY 1 #define HAS_USBKEY 1 diff --git a/MCUME_teensy/teensynofrendo/teensynofrendo.ino b/MCUME_teensy/teensynofrendo/teensynofrendo.ino index 84d2d98..cbfb26b 100644 --- a/MCUME_teensy/teensynofrendo/teensynofrendo.ino +++ b/MCUME_teensy/teensynofrendo/teensynofrendo.ino @@ -274,32 +274,31 @@ void loop(void) #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); #ifdef HAS_T4_VGA - sgtl5000_1.enable(); - sgtl5000_1.volume(0.6); + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); #endif - AudioMemory(16); mymixer.start(); } diff --git a/MCUME_teensy/teensyo2em/AudioPlaySystem.cpp b/MCUME_teensy/teensyo2em/AudioPlaySystem.cpp index 8fea18d..0d156b3 100644 --- a/MCUME_teensy/teensyo2em/AudioPlaySystem.cpp +++ b/MCUME_teensy/teensyo2em/AudioPlaySystem.cpp @@ -68,8 +68,6 @@ static Channel chan[6] = { volatile bool playing = false; - - static void snd_Reset(void) { #ifndef CUSTOM_SND @@ -90,22 +88,22 @@ static void snd_Reset(void) #ifdef CUSTOM_SND -extern "C" { +//extern "C" { void SND_Process(void *sndbuffer, int sndn); -} +//} #endif -static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND +#ifdef CUSTOM_SND SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -135,14 +133,14 @@ static void snd_Mixer(short * stream, int len ) void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - //setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } @@ -151,14 +149,14 @@ void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } bool AudioPlaySystem::isPlaying(void) @@ -166,22 +164,24 @@ bool AudioPlaySystem::isPlaying(void) return playing; } +#ifndef HAS_T4_VGA void AudioPlaySystem::update(void) { - audio_block_t *block; + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND @@ -195,4 +195,3 @@ void AudioPlaySystem::sound(int C, int F, int V) { void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensyo2em/AudioPlaySystem.h b/MCUME_teensy/teensyo2em/AudioPlaySystem.h index 0333adb..7b775ae 100644 --- a/MCUME_teensy/teensyo2em/AudioPlaySystem.h +++ b/MCUME_teensy/teensyo2em/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +//#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensyo2em/teensyo2em.ino b/MCUME_teensy/teensyo2em/teensyo2em.ino index 3cd8348..7860708 100644 --- a/MCUME_teensy/teensyo2em/teensyo2em.ino +++ b/MCUME_teensy/teensyo2em/teensyo2em.ino @@ -273,32 +273,31 @@ void loop(void) #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); #ifdef HAS_T4_VGA - sgtl5000_1.enable(); - sgtl5000_1.volume(0.6); + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); #endif - AudioMemory(16); mymixer.start(); } diff --git a/MCUME_teensy/teensypce/AudioPlaySystem.cpp b/MCUME_teensy/teensypce/AudioPlaySystem.cpp index cdcd71b..0d156b3 100644 --- a/MCUME_teensy/teensypce/AudioPlaySystem.cpp +++ b/MCUME_teensy/teensypce/AudioPlaySystem.cpp @@ -68,9 +68,7 @@ static Channel chan[6] = { volatile bool playing = false; - - -PROGMEM static void snd_Reset(void) +static void snd_Reset(void) { #ifndef CUSTOM_SND chan[0].vol = 0; @@ -90,20 +88,22 @@ PROGMEM static void snd_Reset(void) #ifdef CUSTOM_SND +//extern "C" { void SND_Process(void *sndbuffer, int sndn); +//} #endif -PROGMEM static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND +#ifdef CUSTOM_SND SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -131,57 +131,59 @@ PROGMEM static void snd_Mixer(short * stream, int len ) } } -PROGMEM void AudioPlaySystem::begin(void) +void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } -PROGMEM void AudioPlaySystem::start(void) +void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } -PROGMEM void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { +void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { } -PROGMEM void AudioPlaySystem::reset(void) +void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } -PROGMEM void AudioPlaySystem::stop(void) +void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } -PROGMEM bool AudioPlaySystem::isPlaying(void) +bool AudioPlaySystem::isPlaying(void) { return playing; } -PROGMEM void AudioPlaySystem::update(void) { - audio_block_t *block; +#ifndef HAS_T4_VGA +void AudioPlaySystem::update(void) { + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif -PROGMEM void AudioPlaySystem::sound(int C, int F, int V) { +void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND if (C < 6) { chan[C].vol = V; @@ -190,7 +192,6 @@ PROGMEM void AudioPlaySystem::sound(int C, int F, int V) { #endif } -PROGMEM void AudioPlaySystem::step(void) { +void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensypce/AudioPlaySystem.h b/MCUME_teensy/teensypce/AudioPlaySystem.h index 0333adb..db34b9d 100644 --- a/MCUME_teensy/teensypce/AudioPlaySystem.h +++ b/MCUME_teensy/teensypce/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensypce/platform_config.h b/MCUME_teensy/teensypce/platform_config.h index d21db48..b92c051 100644 --- a/MCUME_teensy/teensypce/platform_config.h +++ b/MCUME_teensy/teensypce/platform_config.h @@ -5,7 +5,7 @@ #define HAS_T41 1 #define HAS_T4_VGA 1 -//#define HAS_SND 1 +#define HAS_SND 1 //#define INVX 1 //#define INVY 1 #define HAS_USBKEY 1 diff --git a/MCUME_teensy/teensypce/teensypce.ino b/MCUME_teensy/teensypce/teensypce.ino index a3c3a6a..ec6ddc1 100644 --- a/MCUME_teensy/teensypce/teensypce.ino +++ b/MCUME_teensy/teensypce/teensypce.ino @@ -270,32 +270,31 @@ void loop(void) #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); #ifdef HAS_T4_VGA - sgtl5000_1.enable(); - sgtl5000_1.volume(0.6); + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); #endif - AudioMemory(16); mymixer.start(); } diff --git a/MCUME_teensy/teensysms/AudioPlaySystem.cpp b/MCUME_teensy/teensysms/AudioPlaySystem.cpp index cdcd71b..0d156b3 100644 --- a/MCUME_teensy/teensysms/AudioPlaySystem.cpp +++ b/MCUME_teensy/teensysms/AudioPlaySystem.cpp @@ -68,9 +68,7 @@ static Channel chan[6] = { volatile bool playing = false; - - -PROGMEM static void snd_Reset(void) +static void snd_Reset(void) { #ifndef CUSTOM_SND chan[0].vol = 0; @@ -90,20 +88,22 @@ PROGMEM static void snd_Reset(void) #ifdef CUSTOM_SND +//extern "C" { void SND_Process(void *sndbuffer, int sndn); +//} #endif -PROGMEM static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND +#ifdef CUSTOM_SND SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -131,57 +131,59 @@ PROGMEM static void snd_Mixer(short * stream, int len ) } } -PROGMEM void AudioPlaySystem::begin(void) +void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } -PROGMEM void AudioPlaySystem::start(void) +void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } -PROGMEM void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { +void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { } -PROGMEM void AudioPlaySystem::reset(void) +void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } -PROGMEM void AudioPlaySystem::stop(void) +void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } -PROGMEM bool AudioPlaySystem::isPlaying(void) +bool AudioPlaySystem::isPlaying(void) { return playing; } -PROGMEM void AudioPlaySystem::update(void) { - audio_block_t *block; +#ifndef HAS_T4_VGA +void AudioPlaySystem::update(void) { + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif -PROGMEM void AudioPlaySystem::sound(int C, int F, int V) { +void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND if (C < 6) { chan[C].vol = V; @@ -190,7 +192,6 @@ PROGMEM void AudioPlaySystem::sound(int C, int F, int V) { #endif } -PROGMEM void AudioPlaySystem::step(void) { +void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensysms/AudioPlaySystem.h b/MCUME_teensy/teensysms/AudioPlaySystem.h index 0333adb..7b775ae 100644 --- a/MCUME_teensy/teensysms/AudioPlaySystem.h +++ b/MCUME_teensy/teensysms/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +//#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensysms/platform_config.h b/MCUME_teensy/teensysms/platform_config.h index 6afc3f4..b098960 100644 --- a/MCUME_teensy/teensysms/platform_config.h +++ b/MCUME_teensy/teensysms/platform_config.h @@ -5,7 +5,7 @@ #define HAS_T41 1 #define HAS_T4_VGA 1 -//#define HAS_SND 1 +#define HAS_SND 1 //#define INVX 1 //#define INVY 1 #define HAS_USBKEY 1 diff --git a/MCUME_teensy/teensysms/teensysms.ino b/MCUME_teensy/teensysms/teensysms.ino index d8131a4..37232ed 100644 --- a/MCUME_teensy/teensysms/teensysms.ino +++ b/MCUME_teensy/teensysms/teensysms.ino @@ -277,31 +277,33 @@ void loop(void) } } - #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); - AudioMemory(16); +#ifdef HAS_T4_VGA + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); +#endif mymixer.start(); } diff --git a/MCUME_teensy/teensyspeccy/.DS_Store b/MCUME_teensy/teensyspeccy/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -135,14 +133,14 @@ static void snd_Mixer(short * stream, int len ) void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - //setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } @@ -151,14 +149,14 @@ void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } bool AudioPlaySystem::isPlaying(void) @@ -166,22 +164,24 @@ bool AudioPlaySystem::isPlaying(void) return playing; } +#ifndef HAS_T4_VGA void AudioPlaySystem::update(void) { - audio_block_t *block; + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND @@ -198,4 +198,3 @@ void AudioPlaySystem::step(void) { void AudioPlaySystem::buzz(int size, int val) { } #endif - diff --git a/MCUME_teensy/teensyspeccy/AudioPlaySystem.h b/MCUME_teensy/teensyspeccy/AudioPlaySystem.h index 0333adb..7b775ae 100644 --- a/MCUME_teensy/teensyspeccy/AudioPlaySystem.h +++ b/MCUME_teensy/teensyspeccy/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +//#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensyspeccy/platform_config.h b/MCUME_teensy/teensyspeccy/platform_config.h index cd91334..5966a69 100644 --- a/MCUME_teensy/teensyspeccy/platform_config.h +++ b/MCUME_teensy/teensyspeccy/platform_config.h @@ -4,7 +4,7 @@ //#define OLD_LAYOUT 1 #define HAS_T4_VGA 1 -//#define HAS_SND 1 +#define HAS_SND 1 //#define INVX 1 //#define INVY 1 #define HAS_USBKEY 1 diff --git a/MCUME_teensy/teensyspeccy/teensyspeccy.ino b/MCUME_teensy/teensyspeccy/teensyspeccy.ino index f9b43ef..4107a3b 100644 --- a/MCUME_teensy/teensyspeccy/teensyspeccy.ino +++ b/MCUME_teensy/teensyspeccy/teensyspeccy.ino @@ -273,32 +273,31 @@ void loop(void) #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); #ifdef HAS_T4_VGA - sgtl5000_1.enable(); - sgtl5000_1.volume(0.6); + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); #endif - AudioMemory(16); mymixer.start(); } diff --git a/MCUME_teensy/teensyvcs/AudioPlaySystem.cpp b/MCUME_teensy/teensyvcs/AudioPlaySystem.cpp index 8fea18d..0d156b3 100644 --- a/MCUME_teensy/teensyvcs/AudioPlaySystem.cpp +++ b/MCUME_teensy/teensyvcs/AudioPlaySystem.cpp @@ -68,8 +68,6 @@ static Channel chan[6] = { volatile bool playing = false; - - static void snd_Reset(void) { #ifndef CUSTOM_SND @@ -90,22 +88,22 @@ static void snd_Reset(void) #ifdef CUSTOM_SND -extern "C" { +//extern "C" { void SND_Process(void *sndbuffer, int sndn); -} +//} #endif -static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND +#ifdef CUSTOM_SND SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -135,14 +133,14 @@ static void snd_Mixer(short * stream, int len ) void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - //setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } @@ -151,14 +149,14 @@ void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } bool AudioPlaySystem::isPlaying(void) @@ -166,22 +164,24 @@ bool AudioPlaySystem::isPlaying(void) return playing; } +#ifndef HAS_T4_VGA void AudioPlaySystem::update(void) { - audio_block_t *block; + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND @@ -195,4 +195,3 @@ void AudioPlaySystem::sound(int C, int F, int V) { void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensyvcs/AudioPlaySystem.h b/MCUME_teensy/teensyvcs/AudioPlaySystem.h index 0333adb..7b775ae 100644 --- a/MCUME_teensy/teensyvcs/AudioPlaySystem.h +++ b/MCUME_teensy/teensyvcs/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +//#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensyvcs/teensyvcs.ino b/MCUME_teensy/teensyvcs/teensyvcs.ino index c6efd9d..27dc1a6 100644 --- a/MCUME_teensy/teensyvcs/teensyvcs.ino +++ b/MCUME_teensy/teensyvcs/teensyvcs.ino @@ -270,35 +270,33 @@ void loop(void) } - #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); #ifdef HAS_T4_VGA - sgtl5000_1.enable(); - sgtl5000_1.volume(0.6); + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); #endif - AudioMemory(16); mymixer.start(); } diff --git a/MCUME_teensy/teensyvectrex/AudioPlaySystem.cpp b/MCUME_teensy/teensyvectrex/AudioPlaySystem.cpp index 8fea18d..0d156b3 100644 --- a/MCUME_teensy/teensyvectrex/AudioPlaySystem.cpp +++ b/MCUME_teensy/teensyvectrex/AudioPlaySystem.cpp @@ -68,8 +68,6 @@ static Channel chan[6] = { volatile bool playing = false; - - static void snd_Reset(void) { #ifndef CUSTOM_SND @@ -90,22 +88,22 @@ static void snd_Reset(void) #ifdef CUSTOM_SND -extern "C" { +//extern "C" { void SND_Process(void *sndbuffer, int sndn); -} +//} #endif -static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND +#ifdef CUSTOM_SND SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -135,14 +133,14 @@ static void snd_Mixer(short * stream, int len ) void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - //setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } @@ -151,14 +149,14 @@ void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } bool AudioPlaySystem::isPlaying(void) @@ -166,22 +164,24 @@ bool AudioPlaySystem::isPlaying(void) return playing; } +#ifndef HAS_T4_VGA void AudioPlaySystem::update(void) { - audio_block_t *block; + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND @@ -195,4 +195,3 @@ void AudioPlaySystem::sound(int C, int F, int V) { void AudioPlaySystem::step(void) { } #endif - diff --git a/MCUME_teensy/teensyvectrex/AudioPlaySystem.h b/MCUME_teensy/teensyvectrex/AudioPlaySystem.h index 0333adb..7b775ae 100644 --- a/MCUME_teensy/teensyvectrex/AudioPlaySystem.h +++ b/MCUME_teensy/teensyvectrex/AudioPlaySystem.h @@ -3,26 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +//#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif + +#endif diff --git a/MCUME_teensy/teensyvectrex/teensyvectrex.ino b/MCUME_teensy/teensyvectrex/teensyvectrex.ino index f8948c4..4f65da1 100644 --- a/MCUME_teensy/teensyvectrex/teensyvectrex.ino +++ b/MCUME_teensy/teensyvectrex/teensyvectrex.ino @@ -280,28 +280,31 @@ void loop(void) #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); - AudioMemory(16); +#ifdef HAS_T4_VGA + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); +#endif mymixer.start(); } diff --git a/MCUME_teensy41/teensyuae41/AudioPlaySystem.cpp b/MCUME_teensy41/teensyuae41/AudioPlaySystem.cpp index 091bcad..0d156b3 100644 --- a/MCUME_teensy41/teensyuae41/AudioPlaySystem.cpp +++ b/MCUME_teensy41/teensyuae41/AudioPlaySystem.cpp @@ -68,9 +68,7 @@ static Channel chan[6] = { volatile bool playing = false; - - -PROGMEM static void snd_Reset(void) +static void snd_Reset(void) { #ifndef CUSTOM_SND chan[0].vol = 0; @@ -90,20 +88,22 @@ PROGMEM static void snd_Reset(void) #ifdef CUSTOM_SND +//extern "C" { void SND_Process(void *sndbuffer, int sndn); +//} #endif -PROGMEM static void snd_Mixer(short * stream, int len ) + +FASTRUN void AudioPlaySystem::snd_Mixer(short * stream, int len ) { if (playing) { -#ifdef CUSTOM_SND +#ifdef CUSTOM_SND SND_Process((void*)stream, len); #else int i; - long s; - len = len >> 1; - + long s; + len = len >> 1; short v0=chan[0].vol; short v1=chan[1].vol; short v2=chan[2].vol; @@ -131,57 +131,59 @@ PROGMEM static void snd_Mixer(short * stream, int len ) } } -PROGMEM void AudioPlaySystem::begin(void) +void AudioPlaySystem::begin(void) { - //emu_printf("AudioPlaySystem constructor"); - this->reset(); - setSampleParameters(CLOCKFREQ, SAMPLERATE); + this->reset(); } -PROGMEM void AudioPlaySystem::start(void) +void AudioPlaySystem::start(void) { - //emu_printf("allocating sound buf"); +#ifndef HAS_T4_VGA + AudioMemory(16); +#endif playing = true; } -PROGMEM void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { +void AudioPlaySystem::setSampleParameters(float clockfreq, float samplerate) { } -PROGMEM void AudioPlaySystem::reset(void) +void AudioPlaySystem::reset(void) { - snd_Reset(); + snd_Reset(); } -PROGMEM void AudioPlaySystem::stop(void) +void AudioPlaySystem::stop(void) { - //__disable_irq(); - playing = false; - //__enable_irq(); + //__disable_irq(); + playing = false; + //__enable_irq(); } -PROGMEM bool AudioPlaySystem::isPlaying(void) +bool AudioPlaySystem::isPlaying(void) { return playing; } -PROGMEM void AudioPlaySystem::update(void) { - audio_block_t *block; +#ifndef HAS_T4_VGA +void AudioPlaySystem::update(void) { + audio_block_t *block; - // only update if we're playing - if (!playing) return; + // only update if we're playing + if (!playing) return; - // allocate the audio blocks to transmit - block = allocate(); - if (block == NULL) return; + // allocate the audio blocks to transmit + block = allocate(); + if (block == NULL) return; snd_Mixer((short*)block->data,AUDIO_BLOCK_SAMPLES); //memset( (void*)block->data, 0, AUDIO_BLOCK_SAMPLES*2); - transmit(block); - release(block); + transmit(block); + release(block); } +#endif -PROGMEM void AudioPlaySystem::sound(int C, int F, int V) { +void AudioPlaySystem::sound(int C, int F, int V) { #ifndef CUSTOM_SND if (C < 6) { chan[C].vol = V; @@ -190,8 +192,6 @@ PROGMEM void AudioPlaySystem::sound(int C, int F, int V) { #endif } -PROGMEM void AudioPlaySystem::step(void) { +void AudioPlaySystem::step(void) { } #endif - - diff --git a/MCUME_teensy41/teensyuae41/AudioPlaySystem.h b/MCUME_teensy41/teensyuae41/AudioPlaySystem.h index 27dc055..7b775ae 100644 --- a/MCUME_teensy41/teensyuae41/AudioPlaySystem.h +++ b/MCUME_teensy41/teensyuae41/AudioPlaySystem.h @@ -3,27 +3,52 @@ #ifdef HAS_SND +#include "platform_config.h" + +//#undef HAS_T4_VGA // To force using Audio library!! + +#ifndef HAS_T4_VGA + #include class AudioPlaySystem : public AudioStream { public: - AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } - void begin(void); - void setSampleParameters(float clockfreq, float samplerate); - void reset(void); + AudioPlaySystem(void) : AudioStream(0, NULL) { begin(); } + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); void start(void); - void stop(void); + void stop(void); bool isPlaying(void); - void sound(int C, int F, int V); + void sound(int C, int F, int V); void buzz(int size, int val); void step(void); private: - virtual void update(void); + virtual void update(void); + static void snd_Mixer(short * stream, int len ); +}; + +#else +class AudioPlaySystem +{ +public: + AudioPlaySystem(void) { }; + void begin(void); + void setSampleParameters(float clockfreq, float samplerate); + void reset(void); + void start(void); + void stop(void); + bool isPlaying(void); + void sound(int C, int F, int V); + void buzz(int size, int val); + void step(void); + static void snd_Mixer(short * stream, int len ); }; -#endif #endif +#endif +#endif diff --git a/MCUME_teensy41/teensyuae41/emuapi.cpp b/MCUME_teensy41/teensyuae41/emuapi.cpp index 743c8f1..a001cf6 100644 --- a/MCUME_teensy41/teensyuae41/emuapi.cpp +++ b/MCUME_teensy41/teensyuae41/emuapi.cpp @@ -7,10 +7,10 @@ extern "C" { #ifdef HAS_T4_VGA #include "vga_t_dma.h" -const vga_pixel deflogo[] = { +const int16_t deflogo[] = { 0,0 }; -static const vga_pixel * logo = deflogo; +static const int16_t * logo = deflogo; #else #include "tft_t_dma.h" const uint16_t deflogo[] = { diff --git a/MCUME_teensy41/teensyuae41/platform_config.h b/MCUME_teensy41/teensyuae41/platform_config.h index 94e7e86..12c5ad6 100644 --- a/MCUME_teensy41/teensyuae41/platform_config.h +++ b/MCUME_teensy41/teensyuae41/platform_config.h @@ -3,10 +3,11 @@ //#define OLD_LAYOUT 1 #define HAS_T4_VGA 1 +//#define HIRES 1 //#define INVX 1 #define INVY 1 -//#define HAS_SND 1 +#define HAS_SND 1 #define HAS_USBKEY 1 //#define HAS_I2CKBD 1 diff --git a/MCUME_teensy41/teensyuae41/teensyuae41.ino b/MCUME_teensy41/teensyuae41/teensyuae41.ino index 9aae49c..81bc8cb 100644 --- a/MCUME_teensy41/teensyuae41/teensyuae41.ino +++ b/MCUME_teensy41/teensyuae41/teensyuae41.ino @@ -202,8 +202,12 @@ void * emu_LineBuffer(int line) void setup() { #ifdef HAS_T4_VGA +#ifdef HIRES tft.begin(VGA_MODE_640x240); - NVIC_SET_PRIORITY(IRQ_QTIMER3, 0); +#else + tft.begin(VGA_MODE_320x240); +#endif + //NVIC_SET_PRIORITY(IRQ_QTIMER3, 0); #else tft.begin(); #endif @@ -274,28 +278,31 @@ void loop(void) #ifdef HAS_SND -#include #include "AudioPlaySystem.h" AudioPlaySystem mymixer; +#ifndef HAS_T4_VGA +#include #if defined(__IMXRT1052__) || defined(__IMXRT1062__) -#ifdef HAS_T4_VGA +//AudioOutputMQS mqs; +//AudioConnection patchCord9(mymixer, 0, mqs, 1); AudioOutputI2S i2s1; AudioConnection patchCord8(mymixer, 0, i2s1, 0); AudioConnection patchCord9(mymixer, 0, i2s1, 1); AudioControlSGTL5000 sgtl5000_1; #else -AudioOutputMQS mqs; -AudioConnection patchCord9(mymixer, 0, mqs, 1); -#endif -#else AudioOutputAnalog dac1; AudioConnection patchCord1(mymixer, dac1); #endif +#endif void emu_sndInit() { Serial.println("sound init"); - AudioMemory(16); +#ifdef HAS_T4_VGA + tft.begin_audio(256, mymixer.snd_Mixer); + // sgtl5000_1.enable(); + // sgtl5000_1.volume(0.6); +#endif mymixer.start(); } diff --git a/MCUME_teensy41/teensyuae41/uae.cpp b/MCUME_teensy41/teensyuae41/uae.cpp index b5e006b..d2e3f18 100644 --- a/MCUME_teensy41/teensyuae41/uae.cpp +++ b/MCUME_teensy41/teensyuae41/uae.cpp @@ -57,10 +57,14 @@ struct uae_prefs currprefs = { /* gfx_width */ WIN_W, /* gfx_height */ WIN_H, #ifdef HAS_T4_VGA +#ifdef HIRES /* gfx_lores */ 0, #else /* gfx_lores */ 1, #endif +#else +/* gfx_lores */ 1, +#endif /* gfx_linedbl */ 0, /* gfx_correct_aspect */ 0, #ifdef HAS_T4_VGA diff --git a/MCUME_teensy41/teensyuae41/vga_t_dma.h b/MCUME_teensy41/teensyuae41/vga_t_dma.h index a15f576..e396ba1 100644 --- a/MCUME_teensy41/teensyuae41/vga_t_dma.h +++ b/MCUME_teensy41/teensyuae41/vga_t_dma.h @@ -15,9 +15,13 @@ - -#define TFT_WIDTH 640 //320 -#define TFT_REALWIDTH 640 //320 +#ifdef HIRES +#define TFT_WIDTH 640 +#define TFT_REALWIDTH 640 +#else +#define TFT_WIDTH 320 +#define TFT_REALWIDTH 320 +#endif #define TFT_HEIGHT 240 #define TFT_REALHEIGHT 240 @@ -44,8 +48,8 @@ class TFT_T_DMA: public VGA_T4 void fillScreenNoDma(vga_pixel color) { clear(color); } void drawTextNoDma(int16_t x, int16_t y, const char * text, vga_pixel fgcolor, vga_pixel bgcolor, bool doublesize) { drawText(x,y,text,fgcolor,bgcolor,doublesize); } void drawRectNoDma(int16_t x, int16_t y, int16_t w, int16_t h, vga_pixel color) { drawRect(x, y, w, h, color); } - void drawSpriteNoDma(int16_t x, int16_t y, const vga_pixel *bitmap) { drawSprite(x, y, bitmap); } - void drawSpriteNoDma(int16_t x, int16_t y, const vga_pixel *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh) { drawSprite(x, y, bitmap, croparx, cropary, croparw, croparh); } + void drawSpriteNoDma(int16_t x, int16_t y, const int16_t *bitmap) { drawSprite(x, y, bitmap); } + void drawSpriteNoDma(int16_t x, int16_t y, const int16_t *bitmap, uint16_t croparx, uint16_t cropary, uint16_t croparw, uint16_t croparh) { drawSprite(x, y, bitmap, croparx, cropary, croparw, croparh); } };