kopia lustrzana https://github.com/Jean-MarcHarvengt/MCUME
add experimental VGAT4 sound support
rodzic
1ec8b17d0e
commit
8dee01b44f
|
@ -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
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
Plik binarny nie jest wyświetlany.
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -275,31 +275,33 @@ void loop(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
Plik binarny nie jest wyświetlany.
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -270,35 +270,33 @@ void loop(void)
|
|||
}
|
||||
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -277,31 +277,33 @@ void loop(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -274,32 +274,31 @@ void loop(void)
|
|||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -273,32 +273,31 @@ void loop(void)
|
|||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -270,32 +270,31 @@ void loop(void)
|
|||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -277,31 +277,33 @@ void loop(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
Plik binarny nie jest wyświetlany.
|
@ -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
|
||||
|
@ -198,4 +198,3 @@ void AudioPlaySystem::step(void) {
|
|||
void AudioPlaySystem::buzz(int size, int val) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -273,32 +273,31 @@ void loop(void)
|
|||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -270,35 +270,33 @@ void loop(void)
|
|||
}
|
||||
|
||||
|
||||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -280,28 +280,31 @@ void loop(void)
|
|||
|
||||
#ifdef HAS_SND
|
||||
|
||||
#include <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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[] = {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <Audio.h>
|
||||
#include "AudioPlaySystem.h"
|
||||
|
||||
AudioPlaySystem mymixer;
|
||||
#ifndef HAS_T4_VGA
|
||||
#include <Audio.h>
|
||||
#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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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); }
|
||||
};
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue