Go Down

Topic: Help with Ardcore Ring Modulator code (Read 3156 times) previous topic - next topic



I'm working on a fairly simple bit of arduino code for my ardcore eurorack module (for those of you who don't know the module I'm talking about http://snazzyfx.com/ardcore.html with the manual here at the top of the page http://snazzyfx.com/instruction.html ) but I can't seem to get the arduino to function how I want it to.

I'm pretty new to arduino and have minimal background in C/C++. Thankfully there are a few example files and premade sketches that come with an ardcore so I've been reverse engineering those patches and trying to create one myself.

My sketch is pretty simple but I can't get it to work properly. My sketch generates a sine wave and multiplies it by the audio input to achieve a ring modulate sound. For some reason I can't get this to work... I'm probably overlooking something simple, some one help please :x


I don't think that reading a single input sample and multiplying by a bunch of different sine wave samples will get what you want.  Don't you have to read one input sample for each output sample?

Here is the existing sketch if anyone else wants to help:
Code: [Select]

//Brandon Bell
//Ardcore Ring Modulator

#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#ifndef M_PI
#define M_PI (3.141592654)

const int digPin[2] = {3, 4};
const int pinOffset = 5;   
int digState[2] = {HIGH, LOW};

int input;
//int samp;
int zoutput;

void setup()
// Serial.begin(9600);
// pinMode(clkIn, INPUT);
  for (int i=0; i<2; i++) {
    pinMode(digPin[i], OUTPUT);
    digitalWrite(digPin[i], digState[i]);
  for (int i=0; i<8; i++) {
    pinMode(pinOffset+i, OUTPUT);
    digitalWrite(pinOffset+i, LOW);
// attachInterrupt(0, isr, RISING);

void loop () {
        int i,nsamps;
double samp;
        double samp2;
double twopi = 2.0 * M_PI;
double angleincr;
        int input = analogRead(2);

nsamps = analogRead(3)*4;
        angleincr = twopi / nsamps;
for(i=0;i < nsamps; i++){
    samp = sin(angleincr *i);
            samp2 = ((unsigned char)((samp*127.5)+127.5));
            zoutput = (input * samp2);


void dacOutput(int v)
  int tmpVal = v;
  for (int i=0; i<8; i++) {
    digitalWrite(pinOffset + i, tmpVal & 1);
    tmpVal = tmpVal >> 1;

void dacOutput(byte v)
  PORTB = (PORTB & B11100000) | (v >> 3);
  PORTD = (PORTD & B00011111) | ((v & B00000111) << 5);
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp


The way how sketch written ,  float math and slow analogRead you can't get reading faster than 4 ksps, probably much lower, which imply 2 kHz upper limit for sound. Look here for basics of audio processing on 8-bits microcontroller:


Hmm alright. I was just following examples that came with the module to see how they call up the different ports. I'll have to work on optimizing it more once I get it working.

My sketch is definitely a bit of a Frankenstein sketch but I don't quite understand why it wouldn't work. I'll keep at it and post something when I get it working.

Thanks for the help

Go Up