[solved] VS1003b real-time MIDI help: silence in simple demo

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
Post Reply
doth
User
Posts: 2
Joined: Thu 2025-05-01 13:19

[solved] VS1003b real-time MIDI help: silence in simple demo

Post by doth »

SOLVED!!! I finally found a solution! I spent a few hard days for this... The moral of the story is "read the documentation carefully several times"))
I found solution in "rtmidi.pdf" (VS10XX REAL-TIME MIDI INPUT doc):
"After the code is loaded, it is started by writing 0x30 to SCI_AIADDR (0x50 for vs1053b)"

My plugin has " 0x000a, 0x0001, 0x0050" at the end (need 0x0030 instead 0x0050 - because my chip is vs1003b). I tried other plugins but other has not writes to 0x000a register at all!

Anyway Thanks Pasi for email answer earlier!

Hi!

I have previously emailed Pasi about similar issue and got detailed answer. Thanks Pasi for answer and refernce to this forum!

See this fresh topic: viewtopic.php?t=3230
but decided to create a separate one as the conditions and environment may differ slightly (sorry if this is not accepted)

My task:
I want to play very simple real-time MIDI sample (one note demo) with vs1003b using only SPI (SCI/SDI)
My mc: ESP32
My dev environment: no arduino, only ESP-IDF sdk + C; SPI; USB powered

My last problem:
I got ratchet sound after sending more than 6 bytes over SDI to vs1003b with real-time MIDI patch loaded

Last problem solving:
I load patch over SCI with wrong high-low byte sequence

My current problem:
Now I don't hear anything, just silence with any settings and MIDI commands

Important note:
MP3 decoding works fine with same environment - I hear the song without distortion

My questions and possible causes of the problem:

1. I see main settings registers that have the most impact for vs1003 + rtmidi case:
MODE, CLOCKF, AUDATA, VOL (and some secondary: STATUS (write-mode), BASS, DECODE_TIME)


And I has two main events before playing MIDI commands:
- Set MODE with software reset (and with SM_SDINEW)
- Loading real-time MIDI patch

At what point should I set these registers? Some settings before reset? Some between reset and patch loading? Or some/all after reset and patch loading? What values should I use for simple demo? Pasi told me in email MODE can be just default 0x800 - is it really enough for easy demo? Also he told me CLOCKF "allows higher polyphony and effect". Is default values of MODE (ox800) CLOCKF (0x0) enough for demo? What about other registers (AUDATA, VOL)? Can incorrect (or default) values ​​for these settings cause my problem? What a minimal set of required pairs of register-value for my demo case (with any quality)?

2. Should I set special SPI bus speed for this case? Can I use 1 MHz for SPI bus speed in SCI initialization and SDI playing parts?
If default value of CLKI is 12.288 MHz - should I change SPI bus speed to correspond this CLKI?

3. Could the problem be related to the power level?
I power the vs1003 with 3v3 from ESP32 power output pin (works fine for mp3 decoding)

4. Could the problem be related to the lack of pull-up resistor for some pins connected to my ESP32?
All pins connected to ESP32 directly

5. What a minimal demo commands set?
I mean real super minimal set of commands to play at least on note. Is single note-on command (0x90) enough to play this note or this case required any settings with MIDI commands before it?

6. I saw it before and also in the new topic (viewtopic.php?t=3230) about MIDI baudrate (31250 Hz). Should I apply this value to any setting?

7. Any other problems?
Also I would be very grateful for a mini review of my code (only logic part ofc)

I attach my code with implementations of base functions:
vs1003_write_sci, vs1003_write_sdi, vs1003_init, vs1003_midi_init, vs1003_midi_write

In my example I use this functions in main.c like this:

Code: Select all

vs1003_init
vs1003_midi_init
// vs1003_midi_write(0xB0, ...) // settings
vs1003_midi_write(0x90, note, vel)
delay
vs1003_midi_write(0x80, note, vel)
Status of vs1003 on start:

Code: Select all

Read [VS1003_MODE_REG]: [0x800]
Read [VS1003_STATUS_REG]: [0x30]
Read [VS1003_BASS_REG]: [0]
Read [VS1003_CLOCKF_REG]: [0]
Read [VS1003_DECODE_TIME_REG]: [0]
Read [VS1003_AUDATA_REG]: [0x1f40]
Read [VS1003_WRAMADDR_REG]: [0]
Read [VS1003_VOL_REG]: [0]
MIDI realtime patch that I load:

Code: Select all

const unsigned short gVS1053_MIDI_Patch[28] = {
    /*if you don't let GPIO1 = H,please send this patch by spi*/
    0x0007, 0x0001, 0x8050, 0x0006, 0x0014, 0x0030, 0x0715, 0xb080, /* 0 */
    0x3400, 0x0007, 0x9255, 0x3d00, 0x0024, 0x0030, 0x0295, 0x6890, /* 8 */
    0x3400, 0x0030, 0x0495, 0x3d00, 0x0024, 0x2908, 0x4d40, 0x0030, /* 10 */
    0x0200, 0x000a, 0x0001, 0x0050
};
(It is not necessary to answer all questions if there is a shorter answer)
Thanks in advance for any response!
Attachments
vs1003_example.c
(5.5 KiB) Downloaded 80 times
User avatar
pasi
VLSI Staff
Posts: 2183
Joined: Thu 2010-07-15 16:04

Re: [solved] VS1003b real-time MIDI help: silence in simple demo

Post by pasi »

The vs1053-rtmidistart code only works with vs1053b, because the code is linked against vs1053b ROM symbols.

I recommend using the vs1003/vs1053 RT-Midi Input application package (from https://www.vlsi.fi/en/support/software ... tions.html ) and either writing 0x30 (for vs1003b) to AIADDR after loading, or add the values "0x000a,0x0001,0x0030" to the .plg array to write 0x30 to AIADDR automatically.

Some general hints when you have SCI connected:
- In RTMidi mode SCI_AUDATA becomes 0xac45 (reflects 44.1kHz stereo)
- If the RX pin receives UART data before the RTMIDI mode has been activated, it is possible the UART receives a bit pattern that looks like the "jump to monitor character" (0xef). When this happens, the execution is stuck in the monitor. You can read and write SCI registers, but the firmware won't service the reads and writes.
- If you write MIDI data through SDI, send a zero byte after every MIDI byte. In effect send 16-bit values with the midi byte on the top 8 bits of the 16-bit value.
- The non-percussion channels have piano as their default instrument, so the minimum is to start the code and send a note On, e.g. 0x9000 0x3c00 0x7f00 (or 0x90 0x3c 0x7f through UART).
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
doth
User
Posts: 2
Joined: Thu 2025-05-01 13:19

Re: [solved] VS1003b real-time MIDI help: silence in simple demo

Post by doth »

Thanks for your hints Pasi!

I have one more question about MIDI instruments:

Can I upload my custom sound and create a new (or replace an existing) instrument? For example, a cat meow sound or just a 440Hz sound or any other sound I want?
User avatar
pasi
VLSI Staff
Posts: 2183
Joined: Thu 2010-07-15 16:04

Re: [solved] VS1003b real-time MIDI help: silence in simple demo

Post by pasi »

There is no sample memory you could load instruments to. There are some instruments using samples or wavetables, but those are in ROM.

There is no standard mechanism to replace instruments. I have patched some instruments in the RT MIDI Application, but generating new ones require a lot of information about the internals, and there is no documentation for someone else to do anything useful.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Post Reply