Coder Social home page Coder Social logo

ml_synthtools's People

Contributors

copych avatar marcel-licence avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ml_synthtools's Issues

MidiStreamPlayer - function to check if the player is still playing music or not?

Hello @marcel-licence ,

Is there a function or a way to check if the MIDI stream player is playing the MIDI file, or already stopped?

I examined the midi_stream_player.h on this and it looks like there are no functions to deal with the checking.

I'm actually writing a bit of a small MIDI player jukebox code and it could be great if the player could send a signal or to do something when the player is stopped. :D

Arduino Compile warning on midi_interface.h

The latest Arduino IDE with the latest arduino-pico generates a warning on printf syntax.

The current code has several lines similar to this ...
Serial.printf("Setup Serial2 with %d baud with rx: "PIN_CAPTION"%d only\n", MIDI_SERIAL2_BAUDRATE, MIDI_RX2_PIN);

These should be changed to somethings similar to this ...
Serial.printf("Setup Serial2 with %d baud with rx: %s%d only\n", MIDI_SERIAL2_BAUDRATE, PIN_CAPTION, MIDI_RX2_PIN);

Support for ESP32S3 and ESP32 Arduino core 3.0.0?

Hi Marcel Licence,

I have attempted to use this ML_SynthTools on the ESP32S3 board and could not get a correct sound output (Midi Stream Player) using the MAX98357A module. The output is mostly noise and it could be a wrong setting in the library.

It is suspected that the I2S drivers used are only for ESP32 and using the older ESP-IDF 4.x.

Any plans on porting this on the ESP32S3 and on newer versions of ESP32 Arduino core such as 3.0.0?

RP2040 using other than PWM0 (solution)

The current DMA code in RP2040_AudioPwm.cpp always manipulates PWM0. In the following code I have changed the PWM_BASE value to using the pwm_hw->slice[] value for the COUNT COMPARE.

(See commented out parameter followed by new parameter)

dma_channel_configure(
                      audio_dma_ch, 
                      &audio_dma_ch_cfg, 
                      // (void *)(PWM_BASE + PWM_CH0_CC_OFFSET),  // Write to PWM counter compare
                      &pwm_hw->slice[audio_pwm_slice_num].cc,     // Write to PWM counter compare
                      &(audio_buffer_a[0]), 
                      buffSize, 
                      false
          );

With this change, the proper slice is used based on the value of RP2040_AUDIO_PWM_PIN.

ESP32 enhancement

Hello @marcel-licence, probably you've already seen this hint, which gives ~30% performance increase of float division according to my tests with Arduino IDE and ESP Arduino-SDK 2.0.6 . I thought, that this may help someday, so I'll leave it here for your attention.
https://blog.llandsmeer.com/tech/2021/04/08/esp32-s2-fpu.html

static __attribute__((always_inline)) inline float one_div(float a) {
    float result;
    asm volatile (
        "wfr f1, %1"          "\n\t"
        "recip0.s f0, f1"     "\n\t"
        "const.s f2, 1"       "\n\t"
        "msub.s f2, f1, f0"   "\n\t"
        "maddn.s f0, f0, f2"  "\n\t"
        "const.s f2, 1"       "\n\t"
        "msub.s f2, f1, f0"   "\n\t"
        "maddn.s f0, f0, f2"  "\n\t"
        "rfr %0, f0"          "\n\t"
        : "=r" (result)
        : "r" (a)
        : "f0","f1","f2"
    );
    return result;
}

and then replace
a = b / c;
with
a = b * one_div(c);

PS float is not that precise (6-7 digits at best), you know. Funny thing is that both float division and this asm insertion accumulate errors in 5th significant digit already after 1000 continuous divisions, and the results differ.

Esp32s3 new sampler example

Hello, @marcel-licence, I have noticed the new promising example -- a sampler with sf support, but I couldn't compile it for ESP32S3, cause you probably haven't updated a compiled library under /src/esp32s3. Will you, please? ))

to trully fix ESP32S3 I2S interface...

Here are some not usual #ifdef

#ifdef ARDUINO_RUNNING_CORE
.mck_io_num = I2S_PIN_NO_CHANGE,
#endif

change these to

#ifdef ARDUINO_RUNNING_CORE
#ifndef CONFIG_IDF_TARGET_ESP32S3
    .mck_io_num = I2S_PIN_NO_CHANGE,
#else
    .mck_io_num = I2S_MCLK_PIN,
#endif
#endif

Also

#ifdef ES8388_ENABLED
REG_WRITE(PIN_CTRL, 0xFFFFFFF0);
#ifdef FUNC_GPIO0_CLK_OUT1
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
#endif
#endif

	#ifndef CONFIG_IDF_TARGET_ESP32S3
    REG_WRITE(PIN_CTRL, 0xFFFFFFF0);
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
	#endif

ESP32 S3 Precompiled

Using the newer ESP32 S3 does not have any precompiled code.

Initial error:
Precompiled library in "c:\Users\ms\Documents\Arduino\libraries\ML_SynthTools\src\esp32s3" not found

Initial error with precompiled library some ldflags thing

Ok - trying to start with an ESP32 and DAC
installed your (this) library manually

Can't compile because of this - and I just don't know anything about it - don't see any obvious advice to resolve. So would be a service if you can help me understand what is wrong? Version or something
Library ML_SynthTools has been declared precompiled:
Using precompiled library in /home/owner/Arduino/libraries/ML_SynthTools/src/esp32
The plaform does not support 'compiler.libraries.ldflags' for precompiled libraries.

missing predefines in midi_via_ble.h

Hello Marcel,
I got some compiler errors while trying the ble-midi-module. I think the predefinitions in midi_via_ble.h got lost somehow. By adding the definitions like this it worked like a charm.

#ifdef ML_SYNTH_INLINE_DECLARATION
void midi_ble_setup();
void midi_ble_loop();
void Ble_rawMsg(uint8_t msg);
void Ble_NoteOn(uint8_t ch, uint8_t note, uint8_t vel);
void Ble_NoteOff(uint8_t ch, uint8_t note);
void Ble_ControlChange(uint8_t ch, uint8_t number, uint8_t value);
void Ble_PitchBend(uint8_t ch, uint16_t bend);
void Ble_RttMsg(uint8_t msg);
void Ble_SongPos(uint16_t pos);
#endif /
ML_SYNTH_INLINE_DECLARATION */

Best regards, Ron

ESP32-AudioKit ES8388 - I2C Init errors and no audio output

I'm trying to execute EPiano and synth organ examples on my just arrived ESP32-AudioKit equipped with ES8388.

The board works with other libraries (arduino-audio-tool & arduino-audiokit), but I can't get working with this library.

I changed board_audio_kit_es8388.h with following:

#define ES8388_CFG_I2C 2
#define ES8388_CFG_I2S 5

I also changed the config.h of example file to use Audiokit with ES8388:

#define BOARD_ESP32_AUDIO_KIT_ES8388 /* activate this when using the ESP32 Audio Kit v2.2 with the ES8388 codec */

At the boot, the serial console returns some errors about I2C CODEC initialization. I can play MIDI notes and they are printed in serial console, but no audio .

Here the boot log

rst:0x1 (POWERON_RESET),boot:0x1f (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13964
load:0x40080400,len:3600
entry 0x400805f0
[  1104][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz

Loading data
Firmware started successfully
Initialize Audio Interface
Connect to ES8388 codec... [  2365][I][esp32-hal-i2c.c:75] i2cInit(): Initialising I2C Master: sda=33 scl=32 freq=400000
0x00: 0x05
[  2470][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
0x01: 0x40
[  2483][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
[  2487][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
STEP1[  2509][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
STEP2STEP3AdcCh1!
MixChAMPL!
[  2527][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
[  2530][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
ES8388 setup finished!
Reg 0x00 = 0x05
[  2552][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x01 = 0x40
[  2568][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x02 = 0x00
[  2582][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x03 = 0x00
[  2596][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x04 = 0x3c
[  2610][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x05 = 0x00
[  2624][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x06 = 0x00
[  2637][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x07 = 0x7c
[  2651][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x08 = 0x00
[  2665][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x09 = 0x88
[  2679][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x0a = 0x50
[  2693][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x0b = 0x02
[  2707][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x0c = 0x0c
[  2721][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x0d = 0x02
[  2735][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x0e = 0x30
[  2749][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x0f = 0x20
[  2762][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x10 = 0x00
[  2776][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x11 = 0x00
[  2790][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x12 = 0x16
[  2804][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x13 = 0xb0
[  2818][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x14 = 0x32
[  2832][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x15 = 0x06
[  2846][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x16 = 0x00
[  2860][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x17 = 0x18
[  2874][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x18 = 0x02
[  2887][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x19 = 0x22
[  2901][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x1a = 0x00
[  2915][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x1b = 0x02
[  2929][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x1c = 0x08
[  2943][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x1d = 0x00
[  2957][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x1e = 0x1f
[  2971][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x1f = 0xf7
[  2985][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x20 = 0xfd
[  2999][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x21 = 0xff
[  3012][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x22 = 0x1f
[  3026][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x23 = 0xf7
[  3040][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x24 = 0xfd
[  3054][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x25 = 0xff
[  3068][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x26 = 0x1b
[  3082][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x27 = 0xb8
[  3096][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x28 = 0x28
[  3110][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x29 = 0x28
[  3124][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x2a = 0xb8
[  3137][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x2b = 0x80
[  3151][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x2c = 0x00
[  3165][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x2d = 0x00
[  3179][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x2e = 0x1e
[  3193][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x2f = 0x1e
[  3207][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x30 = 0x1e
[  3221][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x31 = 0x1e
[  3235][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x32 = 0x00
[  3249][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x33 = 0xaa
[  3262][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
Reg 0x34 = 0xaa
[  3276][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
[  3280][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
[  3293][E][Wire.cpp:416] beginTransmission(): Unfinished Repeated Start transaction! Expected requestFrom, not beginTransmission! Clearing...
I2S configured using following pins:
    BCLK,BCK: 27
    WCLK,LCK: 25
    DOUT: 26
    DIN: 35
MIDI listen on Serial with 115200 baud
Setup Serial2 with 115200 baud with rx: IO21 only
Setup MidiPort2 using Serial2
rev: 15329, 15329
Reverb is ready!
ESP.getFreeHeap() 174104
ESP.getMinFreeHeap() 174072
ESP.getHeapSize() 276752
ESP.getMaxAllocHeap() 110580
Total PSRAM: 0
Free PSRAM: 0
Firmware started successfully
<0x1b>[?25l<0x1b>[0;0HChorus_SetPhaseShift: 0.500     
901c64
>90 1c 64<
801c00
>80 1c 00<
901d64
>90 1d 64<
801d00
>80 1d 00<
901a64
>90 1a 64<
801a00
>80 1a 00<
901c64
>90 1c 64<
801c00
>80 1c 00<

Usage Question: RP2040 with PWM audio out

I am assuming, to use a Raspberry Pi PICO and PWM output, I need to first set the defines for ARDUINO_RASPBERRY_PI_PICO and RP2040_AUDIO_PWM.

(1) What is not clear is the declaration of which GPIO pin(s) to use the code appears to use 0 and 1 but no mechanism to override them?

(2) Are two pins used for mono audio?

ML_SynthTools.a source availability

Will the source for the platform ML_SynthTools.a file(s) be available or do they contain proprietary code?

I am attempting to port the ML_SynthTools library and at least of the the example projects to a different toolchain.

USB_MIDI_ENABLED vs MIDI_USB_ENABLED

There are two definitions - USB_MIDI_ENABLED and MIDI_USB_ENABLED - which appear to be used similarly.

Should these all be one thing or could you explain when each is relevant?

Trying to port to TTGO T9 using WM8978 DAC

First of all, An impressive software.
I have to boards from LilyGO that has all the hardware needed for this to run. I'm at the moment trying to get the TTGO T9 (TAudio) board to work ( https://github.com/LilyGO/TTGO-TAudio ). Tried some sample code from (LilyGO/TTGO-TAudio#12) and it runs. Then tried to remaster a new card following your code but I'm a bit confused with the nesting of "boards" vs DAC vs i2s_interface vs i2s_module.

It might be better to separate hardware and its init ?
Could you give it a try to add this board to the code ?

Lib common used for this DAC
https://github.com/CelliesProjects/wm8978-esp32
https://github.com/schreibfaul1/ESP32-audioI2S

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.