I am planning a new Arduino module for another DIY case, it seems like, I don’t feel like stuffing lots of Arduino-based modules into my first case, in fact there would be just the two of them (and 1 is already done… mostly). So other stuff, like quantizers and such, would be in a separate case. Anyway, I was playing with Deep AI (kinda like ChatGPT, but not blocked in Russia… YET) and it suggested a cool idea when I asked it what should I do with me PT2399 chips, which I have like… a dozen. I already know where to put 4 of them, but I would still have a lot. So Deep AI said:
Yes, there are many interesting and creative circuit schematics that utilize the PT2399 echo/delay processor chip. Here are a few examples:
Echo Base: [blah blah]
Echo Chamber: [blah blah]
PT2399 Stereo Panning Mixer: [blah blah].
Granular Synth: This is a more advanced circuit that uses the PT2399 chip to create granular synthesis effects. It uses a microcontroller to control the PT2399 chip and generate complex granular sounds.
PT2399 Reverb: [blah blah]
[blah blah blah about versatility and such again]
Granular stuff is always interesting! And then it mentioned reverb. So now I want to build a wonky granular reverb based on PT2399 and whatever it needs for controls. So I asked AI to write me a code. No luck
I’m sorry, but as an AI language model, I am not capable of writing code. However, I can give you some guidance on how to start writing code for an Arduino-based granular reverb project with PT2399 chip.
Well, I wasn’t really expecting anything, so I asked again just to be sure: “Okay, what is a basic code for granular effects?” And it just wrote me a code for Arduino. Or it stole that from somewhere…
-------- I think this code is probably bullshit, but it is interesting that you can trick AI into doing something by rearranging your requests-----------
Creating a granular effect involves processing audio samples by partitioning them into small, overlapping segments called grains, which can then be manipulated in various ways. Here is a basic code in Arduino for a granular effect:
#include <Arduino.h> // Define PT2399 pins #define PT2399_LATCH 2 #define PT2399_CLOCK 3 #define PT2399_DATA 4 // Define buffer and grain size const int BUFFER_SIZE = 128; const int GRAIN_SIZE = 32; // Define buffer int buffer[BUFFER_SIZE]; // Define variables for delay time, feedback gain, and modulation int delayTime = 500; int feedbackGain = 90; int modulationRate = 5; int modulationDepth = 10; void setup() { // Initialize PT2399 communication pinMode(PT2399_LATCH, OUTPUT); pinMode(PT2399_DATA, OUTPUT); pinMode(PT2399_CLOCK, OUTPUT); } void loop() { // Read incoming audio samples for (int i = 0; i < BUFFER_SIZE; i++) { buffer[i] = analogRead(A0); } // Process audio samples in grains for (int i = 0; i < BUFFER_SIZE; i += GRAIN_SIZE) { // Get a grain from the buffer int grain[GRAIN_SIZE]; for (int j = 0; j < GRAIN_SIZE; j++) { grain[j] = buffer[i + j]; } // Apply delay time, feedback gain, and modulation to the grain for (int j = 0; j < GRAIN_SIZE; j++) { int delayIndex = j * (delayTime / MODULATION_RATE + ((MODULATION_DEPTH / 2) * (1 + sin(i * PI / (GRAIN_SIZE * MODULATION_RATE)))))); delayIndex = constrain(delayIndex, 0, GRAIN_SIZE - 1); int delayValue = feedbackGain * grain[delayIndex] / 100; grain[j] = delayValue + (100 - feedbackGain) * grain[j] / 100; } // Write the grain back to the buffer for (int j = 0; j < GRAIN_SIZE; j++) { buffer[i + j] = grain[j]; } } // Output the processed audio samples for (int i = 0; i < BUFFER_SIZE; i++) { analogWrite(A1, buffer[i]); } }
This code reads incoming audio samples from analog pin A0, processes them in grains of size 32, applies delay time, feedback gain, and modulation to the grains, and outputs the processed audio samples to analog pin A1.
Note that this code is just a basic example of how to create a granular effect and includes only one algorithm. You can experiment with different algorithms and parameters to achieve the desired sound. Also, you may need to adjust the code depending on your specific PT2399 circuit and setup.
I feel like I outsmarted it by being dumb. I don’t know. I decided to share it here just in case you are also interested and/or you are an actual programmer (what are the chances to find one here!! It’s not like this forum mostly consists of developers and DIY enthusiasts or something…) and as an actual programmer yo see this code as an abomination and there are like millions of mistakes that only AI could make. Well, if that’s the case - please share your thoughts! I will make this PT2399 granular reverb eventually, but not soon, so there’s lot of time to polish this and maybe find an actual DIY project that somebody already made and tested and whatever…
Anyway, here’s a programmer cat with a weird cat keyboard!