Hagiwo Sample Drum under MIDI control

Got it, that worked a ton and it is one of my favorite modules! Thank you so much! Thing is, I have 6 drum modules and a axiom 61 with 8 pressure pads which triggers them fine, but I have no idea how you guys are able to record drum patterns. I have to manually play each individual pad instead of say, recording a bass line and then recording a snare line on top of that, hi hat, etc. What do you guys use?

You need a trigger sequencer.

THE kosmo one is the big button :

Or Hagiwoā€™s :

But there are many others, just google for it.

Then you have the ā€œmore or less randomā€ ones:

Or the Turing Machine:

Youā€™ll need the Pulse expander module for drums

1 Like

Oh I already have the big button sequencer and the oled sequencer, both being really good but I needed something more for midi which I think I already have covered with a MidiRex I just got. Does anyone have one and is it really good for recording midi trigger sequences for drums?

So I got nowhere with this project as I couldnā€™t cleanly create any samples that played successfully and consistently, some were just white noise and others had an annoying pop on the end of them no matter what I did.

So tonight I modified the code slightly to break the samples into individual arrays for each sound rather than a huge 48x58650 array. Now this seems to work perfectly, I have loaded 3 samples up and straight away they play cleanly and without pops, I will do some more testing tomorrow but in theory it also allows for each sample to be any length you need as Iā€™ve also seen instances where crash and ride cymbals are longer than 0.6s for playback.

I will report back tomorrow with hopefully more samples loaded from different sources all playing consistently.

1 Like

Iā€™m following this thread with great interest.
I have a real dyslexic midas touch with sample polyphony, every thing i touch turns to glod!
Best of luck.

1 Like

So Iā€™ve experimented some more and fixed a few issues with the code from my point of view, Iā€™m now playing back 4 samples that were giving me issues last night, I also added a 2% fade out on the end of the playback and that really eliminates any pops remaining on the sample playback. Although these were very minimal now, they were still there and annoying. Even on Hagiwos own sample bank from his Patreon several of the samples pop.

2 Likes

Loaded 39 Bass drum samples so far.

2 Likes

So as a sideline to this drum module project I wanted to see if I could play the samples through a DAC at 16 bit 48khz quality, officially the ESP32-C3 doesnā€™t support i2s to the DAC, but I used some examples I found on the net and got a stereo 1khz test tone working and adapted that to work with the drum sounds. Tonight I finally managed to trigger a drum sound through a pcm1502 stereo DAC at 16 bit and 48khz.

This was on a breadboard and was quite flaky, tomorrow I will hardwire some parts and see if it is more stable.

The main reason for this is that sounds with high frequency spectrums like hihats etc sound awful when converted to 10bits for pwm playback, Iā€™m not sure what Hagiwo did to get clean sounding samples but for me they sound like junk so I want to play back at full bandwidth.

2 Likes

For anyone interested here is the repository for the DAC version of the Hagiwo Drum sample playback module.

It uses a cheap pcm1502a i2s 24bit stereo DAC.

It now includes, volume over MIDI, panning over MIDI as well as the tuning.

The filter has been removed as that was part of the PWM section of the previous version. I donā€™t see any benefits to building stereo filters for the output of the DAC.

https://github.com/craigyjp/Hagiwo-Drum-Sample-playback-with-MIDI-with-DAC

I will update the schematics shortly.

Update: The ESP32-C3 is not capable of playing samples properly via i2s, it sounded OK untilI got to high hat sounds again and it was awful. Not worth bothering with. I think the Seeed XIAO ESP32-S3 is probably the way to go, but Iā€™ve just ported the code to the YD-RP2040 Pico clone and tested again and I can play samples perfectly, the samples actually sound like the originals now. So I think RP2040 with 16Mb is the way to got if I can find some cheap enough.

4 Likes

Experiments with drum modules, after being severely disappointed with the ESP32-C3 and itā€™s lack of proper i2s support I started looking at the Pico as an alternative, now the Pico doesnā€™t have native i2s, but it works if you use the i2s library and configure the PIO to support audio over i2s. The next issue was the Pico only has 2MB of memory and this design needs 4MB in total to hold approx 48 0.6s mono samples.

Switch to the YD-RP2040, an inexpensive clone with 2,4,8 or 16MB version available cheaply. I got 16MB versions for around Ā£5. So with 16MB I have more than enough room for 48 samples, in fact I thought 128 samples to fit in with program changes 1-128. Still have about 50% free space. So why not use the Pico to drive 2 audio boards for playback of two samples. So I added a second card and it worked but I had issues when two samples played together, they sounded weird until one played on its own.

I enabled the second core and ran the second sample playback on that core and problems solved, runs smoothly and clean. So I know Iā€™m probably being stupid and I could run both samples down the same audio board if I werenā€™t so dumb, but this allows individual outs now. Maybe I donā€™t need that but it would be nice. But itā€™s sort of negated by the panning option of the sample. What do people recommend?

2 Likes

Polypraxia* {Noun, a cognitive disjunct resulting in an inability to get ones head around polyphony in a loop process}

Thatā€™s my excuse anyway!
*made up

1 Like

Revisiting this project as I have a little bit of free time and the boards just sitting there. The breadboard was the cause of most of my issues, usually is, bad connections etc caused the second audio card to do strange things, so I built it into a small piece of proto board and tested again, no zipper noises when changing settings over MIDI and the second card works each time.

New idea, enable the second UART for MIDI and use the second core loop to process the second sample fully. First it did not work as I was using the wrong default UART pins, I realised when checking the trigger inputs and one was high because it was on the TX line of the second UART input. I searched around but couldnā€™t find the default pins described anywhere. So by a lucky accident I found them. Moved the second MIDI input to those pins and the triggers elsewhere and tested. Seems ok but the sound crashes when changing pitch occasionally.

Played around with the routines for pitch changes and made a smooth transition rather than sample rate jumps and it seems stable. I will do more testing on this today to make sure itā€™s stable enough for a build. Plan is upto 128 samples per bank, 2 banks per Pico (clone) board. 8 boards in total with 16 audio cards. I plan to add individual outputs by panning the sound hard left and picking up that bu breaking the wire to the mixer section when plugging in the individual jacks (maybe)

Serial 0 is USB

Serial 1 default pins
Gpio 0 TX
Gpio 1 RX

Serial 2 default pins
Gpio 8 TX
Gpio 9 RX

1 Like

FYI just in case you are tempted, some of the 16mb yd-RP2040 do not like being overclocked (>125mhz iirc) and just hang.
I was trying to run Pikocore and could not figure out why it did not work. Apparently some units are fine, others not, I suspect it depends on the batch or type of memory chips?

That said I now have a spare yd-2040 and pcm5201 ā€¦ and to many projects already :rofl:

I donā€™t need to overclock, but thanks for the heads up

One thing I did find when testing was inconsistent triggering of the drums from a 5v pulse, not an issue with a manual trigger but when attached to the drum controller it was very bad.

So I added interrupts to the trigger pins and that has fixed it now, solid triggers of the sounds every time.

Another update, I was limited by the 0.6 second playback time for samples, itā€™s ok for short snappy drums, but a lot of them can sound for upto 1.5 seconds and some are as short as 0.1 sec. So I decided to investigate variable sample lengths for playback and it was easy enough to implement. The size is calculated the the time x 48000, so a 1 second playback the value is 48000, pretty straight forward, each sample has a playback length in an array at the same position as the sample in the sample playback array. As each sample is selected the correct playback length is loaded.

Of course having a Pico clone with approx 16mB of free ram instead of 4mB really helps in removing the limits of the device.

Simples.

3 Likes