Skip to content

Commit 33eb70c

Browse files
added another ES8388 configuration
support TX1 for MIDI
1 parent 1d1bbf3 commit 33eb70c

File tree

6 files changed

+31
-58
lines changed

6 files changed

+31
-58
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ML_SynthTools",
3-
"version": "2.0.4",
3+
"version": "2.0.5",
44
"keywords": "ML_SynthTools, Synthesizer, Filter, Audio, ESP32, ESP32S2, ESP32S3, STM32, RP2040",
55
"description": "Synthesizer Tools; contains waveform generators etc.",
66
"repository":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ML SynthTools
2-
version=2.0.4
2+
version=2.0.5
33
author=Marcel Licence <[email protected]>
44
maintainer=Marcel Licence <[email protected]>
55
sentence=Synthesizer Tools

src/RP2040_AudioPwm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
#define __WAV_PWM_AUDIO_H
5050

5151

52-
#if (defined ARDUINO_ARCH_RP2040)
52+
#if defined(ARDUINO_ARCH_RP2040)
5353
/* ignore */
5454
#else
5555
#error not supported by this platform!
@@ -64,5 +64,5 @@ bool RP2040_Audio_Pwm_BufferReady();
6464
uint32_t *RP2040_Audio_Pwm_getFreeBuff();
6565

6666

67-
#endif /* ARDUINO_ARCH_RP2040 */
67+
#endif /* __WAV_PWM_AUDIO_H */
6868

src/boards/board_audio_kit_es8388.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@
116116
#define ES8388_PIN_LRCK 25
117117
#define ES8388_PIN_SCLK 27
118118
#define ES8388_PIN_MCLK 1
119+
#elif ES8388_CFG_I2S==7
120+
/* DOUT and DIN are swapped used for A247 */
121+
#define ES8388_PIN_DOUT 26
122+
#define ES8388_PIN_DIN 35
123+
#define ES8388_PIN_LRCK 25
124+
#define ES8388_PIN_SCLK 27
125+
#define ES8388_PIN_MCLK 0
119126
#endif
120127

121128

src/midi_interface.h

Lines changed: 18 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
*
3636
* @brief This file contains an implementation of a simple MIDI interpreter to parse incoming messages
3737
*
38-
* MIDI_DUMP_Serial1_TO_SERIAL <- when active received data will be output as hex on serial(1)
39-
* MIDI_SERIAL1_BAUDRATE <- use define to override baud-rate for MIDI, otherwise default of 31250 will be used
40-
*
4138
* @see https://www.midi.org/specifications-old/item/table-1-summary-of-midi-message
4239
*/
4340

@@ -133,9 +130,9 @@ void Midi_SendRaw(uint8_t *msg);
133130
struct midi_port_s
134131
{
135132
Stream *serial; /* this can be software or hardware serial */
136-
uint32_t inMsgWd ;
133+
uint32_t inMsgWd;
137134
uint8_t inMsg[3];
138-
uint8_t inMsgIndex ;
135+
uint8_t inMsgIndex;
139136
};
140137

141138
#if (defined ARDUINO_DAISY_SEED) || (defined STM32H7xx)
@@ -146,12 +143,6 @@ HardwareSerial Serial2(USART1);
146143
HardwareSerial Serial2(USART2); /* PA3 */
147144
#endif
148145

149-
#if 0
150-
#ifdef ARDUINO_GENERIC_F407VGTX
151-
HardwareSerial Serial2(USART3); /* PB11 */
152-
#endif
153-
#endif
154-
155146
#ifdef MIDI_PORT_ACTIVE
156147
struct midi_port_s MidiPort;
157148
#endif
@@ -215,10 +206,6 @@ struct midiMapping_s
215206
void (*rttMsg)(uint8_t msg);
216207
void (*songPos)(uint16_t pos);
217208

218-
#ifdef MIDI_SYSEX_ENABLED
219-
void (*sysEx)(uint8_t *msg, uint8_t len);
220-
#endif
221-
222209
struct midiControllerMapping *controlMapping;
223210
int mapSize;
224211

@@ -283,6 +270,11 @@ inline void Midi_CC_Map(uint8_t channel, uint8_t data1, uint8_t data2, struct mi
283270
{
284271
for (int i = 0; i < mapSize; i++)
285272
{
273+
/*
274+
* in case channel and control number matches or
275+
* in channel bit 0x10 is set, then the bit of the channel is set too and control number matches
276+
*/
277+
286278
if (
287279
((controlMapping[i].channel == channel) && (controlMapping[i].data1 == data1))
288280
|| (((controlMapping[i].channel & 0x10) != 0) && ((controlMapping[i].channel & (1 << channel)) != 0) && (controlMapping[i].data1 == data1))
@@ -581,13 +573,15 @@ void Midi_Setup()
581573
Serial2.setRX(MIDI_RX2_PIN);
582574
#else
583575
Serial.printf("Setup Serial2 with %d baud with rx: Serial2.rx\n", MIDI_SERIAL2_BAUDRATE, PIN_CAPTION);
584-
#endif /* MIDI_RX2_PIN */
576+
#endif
585577
Serial2.begin(MIDI_SERIAL2_BAUDRATE);
578+
586579
#endif /* ARDUINO_ARCH_RP2040 */
587580

588581
MidiPort2.serial = &Serial2;
589582
Midi_PortSetup(&MidiPort2);
590583
Serial.printf("Setup MidiPort2 using Serial2\n");
584+
591585
#endif /* MIDI_PORT2_ACTIVE */
592586

593587
#ifdef USB_MIDI_ENABLED
@@ -610,7 +604,9 @@ void Midi_CheckMidiPort(struct midi_port_s *port, uint8_t cable)
610604
/* ignore live messages */
611605
if ((incomingByte & 0xF0) == 0xF0)
612606
{
613-
Midi_RealTimeMessage(incomingByte);
607+
{
608+
Midi_RealTimeMessage(incomingByte);
609+
}
614610
return;
615611
}
616612

@@ -687,6 +683,8 @@ void Midi_Process()
687683
#endif
688684
}
689685

686+
#ifndef ARDUINO_SEEED_XIAO_M0
687+
#ifndef SWAP_SERIAL
690688
#ifdef MIDI_TX2_PIN
691689
void Midi_SendShortMessage(uint8_t *msg)
692690
{
@@ -722,42 +720,9 @@ void Midi_SendRaw(uint8_t *msg)
722720
MidiPort2.serial->write(msg, 3);
723721
}
724722
}
725-
#elif defined(MIDI_TX1_PIN)
726-
void Midi_SendShortMessage(uint8_t *msg)
727-
{
728-
MidiPort1.serial->write(msg, 3);
729-
}
730-
731-
void Midi_SendRaw(uint8_t *msg)
732-
{
733-
/* sysex */
734-
if (msg[0] == 0xF0)
735-
{
736-
int i = 2;
737-
while (msg[i] != 0xF7)
738-
{
739-
i++;
740-
}
741-
MidiPort1.serial->write(msg, i + 1);
742-
}
743-
else if ((msg[0] & 0xF0) == 0xC0)
744-
{
745-
MidiPort1.serial->write(msg, 2);
746-
}
747-
else if ((msg[0] & 0xF0) == 0xD0)
748-
{
749-
MidiPort1.serial->write(msg, 2);
750-
}
751-
else if ((msg[0] & 0xF0) == 0xF0)
752-
{
753-
MidiPort1.serial->write(msg, 1);
754-
}
755-
else
756-
{
757-
MidiPort1.serial->write(msg, 3);
758-
}
759-
}
760-
#endif /* MIDI_TX1_PIN */
723+
#endif /* MIDI_TX2_PIN */
724+
#endif
725+
#endif
761726

762727
#ifdef MIDI_MAP_FLEX_ENABLED
763728
void Midi_SetMidiMap(struct midiControllerMapping *controlMapping, int mapSize)

src/ml_scratch.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ bool Scratch_AddSampleStatic(const uint8_t *data, uint32_t size, uint8_t idx)
153153
newSample->sample_count = (wavHdr->nextTag.tag_data_size / wavHdr->bytesPerSample);
154154
newSample->loop = true;
155155
newSample->volume = 1 << 15;
156+
156157
if (wavHdr->numberOfChannels == 2)
157158
{
158159
newSample->stereo = true;
@@ -181,8 +182,8 @@ void Scratch_ProcessSample(Q1_14 *samples_l, Q1_14 *samples_r, uint32_t len, str
181182
{
182183
for (uint32_t n = 0 ; n < len; n++)
183184
{
184-
185185
sample->pos = sample->pos_f;
186+
186187
if (sample->stereo)
187188
{
188189
sample->pos -= sample->pos % 2;

0 commit comments

Comments
 (0)