If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Drum machine Project need help!

Hi, after some research, me and my partner are in a blind alley!
We are working on the version 2 of our beloved drum machine Shapeshifter (www.faselunare.com)

the project has grown significantly and has become quite complex.

These are the current hardware specifications

Code:

24 buttons including 16 for the steps
3 potentiometers
1 encoder
1 128-matrix led WS2812C
Each pot/encoder/buttons/jack has his own rgb WS2812C led
Audio Out direct from DAC1 and DAC 2
Midi In
Midi Out
Clock In
Clock Out
Reset
Trig Out 1
Trig Out 2
Trig Out 3
Trig Out 4
Breadboard for prototyping
Expansion board space (we use it now for the display, in the next version we move the breadboard on the right to make space for a bigger display)

The drum now has 4 sample track (1,2,3,4)
The samples are read directly from the SD card (not the onboard SD)

First track is for the Kick Sound and here we have a strange problem, kick samples always sound wrong with huge amount of glitches (we have tried several samples)
We would like to understand with you if the problem is hardware or if there is something wrong in the samples ... would you like to give us a hand?

Checked your samples, there is nothing wrong with them. But you already knew that since your problem persist with the use of AudioSynthSimpleDrum.

It's kind of hard to troubleshoot you problem without the actual hardware but there are two things I would try out first:

Reduce AudioMemory(250) to something more reasonable. Use AudioMemoryUsage() & AudioMemoryUsageMax() to estimate what your project needs.
Although I don't think this will make a difference, it's worth a shot.

Comment everything related to the scheduler lib(include, startLoop(), yield()).
Call readKeypadLoop() from the main loop() and not ledScan(), memoryManagement(), clkOut() assuming they are not essential to run shapeshifter.
See what happens from there. You have three possible outcomes. Problem persists, problem persists but sounds different, problem gone.
My rationale behind above is that the scheduler lib was not used in shapeshifter v1, assuming v1 did not suffer from this problem.
Personally, I would have made use of the variable type elapsedMillis in the main loop to call the functions instead of using the scheduler lib. It just gives you more control.

The Polaron has a pretty similar framework (3.6, uses native DACs). Nothing wrong with its kicks. You might check out the gain staging in your product vs. the Polaron: https://github.com/zueblin/Polaron

The bad news is Adafruit_NeoPixel does not play well with audio, or anything else needing interrupts or CPU time while the LEDs update. It's a "blocking" library, meaning it hogs the CPU while working, so nothing else (like audio) gets to work. You really need to stop using Adafruit_NeoPixel to update the LEDs.

The good news is we do have a non-blockin library to (mostly) replace it, called WS2812Serial. It will work with audio, because it uses DMA to update the LEDs, leaving the CPU and interrupts free for audio and everything else.

But WS2812Serial only supports certain pins. On Teensy 3.6 you can use pins (1, 5, 26), 8, 10, 32, 33. On that page, scroll down to "Supported Pins & Serial Ports" for details.

I didn't look through the *many* other header files in your project to find the definitions of LEDs_PIN and MATRIX_PIN. If you're extremely lucky, maybe you already chose pins among the ones supported by WS2812Serial. But odds are strong you'll need to cut traces on your PCB and solder mod wires to connect the LEDs to pins which can work with WS2812Serial.

Share the code which doesn't compile, the whole thing in a zip file. If using "quick reply", click the "go advanced" button. The advanced editor lets you attach a zip file to your message.

Before you post, please check the zip file by extracting on another computer and load it with Arduino and click Verify. Make sure the zip file's contents really are everything needed to get the exact same error. If you give something incomplete that doesn't really reproduce the same error, that just wastes everyone time.

I will look again in ~12 hours, only 1 more time. Please make it count by truly verifying the file you provide has everything. Maybe others here on this forum will also try, but with me you have 1 more chance. If you upload another zip file missing stuff, that will be the last time I try to compile. I want to help you, but I'm not going to keep wasting time if you do not make the effort to upload a complete file and clearly specify everything I need to install... only to compile you code to help you fix an error!

Or if other libs need to be installed, you must give clear info about everything needed. Leave nothing out.

Usually only the scheduler and the arduinoJson are missing (in our setup)

I'm sorry to waste your time but right now our developer is not available.
I hope to have included all the information you need, I don't know how to include these libraries in the zip so that everything is included and ready to compile, I tried but without result.

With this change, the class definition compiles, but then the LED code has tons of errors because WS2812Serial and Adafruit_NeoPixel have slightly different functions. I've added the Adafruit functions you need. The WS2812Serial.h file is attached, and also committed to github (so these will be in future Teensyduino releases).

This still doesn't give you LEDs.setBrightness(). WS2812Serial doesn't have this feature and it's not something I can do quickly. For now, I recommend you comment out that part of your project and just go with full brightness until you get the sound and LEDs are playing together nicely.

I'm not sure if this is really all the errors, since I'm missing the correct ArduinoJson, but hopefully it helps you get past this hurdle and move forward with fixing the sound problems?

We have to cover the led, are too bright (my partner and I canceled our short-term memory by watching them :-) )
Is not perfect but starts to look like a drum
here is a short video made today, the drum sends a trig signal to the keystep that controls the neutron

Looking at Paul's github, I don't see any additions to brightness control. From what little I know of the ws2812 protocol, I doubt it would really be feasible to add it in a non-blocking way. That's why the FastLED and other libraries use blocking code to achieve it.

Paul is extremely busy working on Teensy 4.1 and the bootloader chip and who knows what else, please understand that.