I have connected a Read() function that reads from a 32 key 64 switch keyboard by reading the rows and columns
When I call that function in the SimpleDrum example no sound is generated. I am not using any pins shared with the audio shield. I honestly have no idea what the issue is. I would also like to add that the Serial Monitor displays no information when Read() is called. Any help would be greatly appreciated
When I call that function in the SimpleDrum example no sound is generated. I am not using any pins shared with the audio shield. I honestly have no idea what the issue is. I would also like to add that the Serial Monitor displays no information when Read() is called. Any help would be greatly appreciated
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthSimpleDrum drum2; //xy=399,244
AudioSynthSimpleDrum drum3; //xy=424,310
AudioSynthSimpleDrum drum1; //xy=431,197
AudioSynthSimpleDrum drum4; //xy=464,374
AudioMixer4 mixer1; //xy=737,265
AudioOutputI2S i2s1; //xy=979,214
AudioConnection patchCord1(drum2, 0, mixer1, 1);
AudioConnection patchCord2(drum3, 0, mixer1, 2);
AudioConnection patchCord3(drum1, 0, mixer1, 0);
AudioConnection patchCord4(drum4, 0, mixer1, 3);
AudioConnection patchCord5(mixer1, 0, i2s1, 0);
AudioConnection patchCord6(mixer1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=930,518
// GUItool: end automatically generated code
static uint32_t next;
boolean keyTable[8][8];
byte cols[] = {24,25,26,27,28,29,30,31};
byte rows[] = {32,33,34,35,36,37,38,39};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// audio library init
AudioMemory(15);
next = millis() + 1000;
AudioNoInterrupts();
drum1.frequency(60);
drum1.length(1500);
drum1.secondMix(0.0);
drum1.pitchMod(0.55);
drum2.frequency(60);
drum2.length(300);
drum2.secondMix(0.0);
drum2.pitchMod(1.0);
drum3.frequency(550);
drum3.length(400);
drum3.secondMix(1.0);
drum3.pitchMod(0.5);
drum4.frequency(1200);
drum4.length(150);
drum4.secondMix(0.0);
drum4.pitchMod(0.0);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
AudioInterrupts();
}
void loop() {
// put your main code here, to run repeatedly:
static uint32_t num = 0;
if(millis() == next)
{
next = millis() + 1000;
switch(num % 4)
{
case 0:
drum1.noteOn();
break;
case 1:
drum2.noteOn();
break;
case 2:
drum3.noteOn();
break;
case 3:
drum4.noteOn();
break;
}
num++;
Serial.print("Diagnostics: ");
Serial.print(AudioProcessorUsageMax());
Serial.print(" ");
Serial.println(AudioMemoryUsageMax());
AudioProcessorUsageMaxReset();
}
Read();
}
void Read()
{
for(int i = 0; i < 8; i++)
{
//change pinMode
pinMode(cols[i], OUTPUT);
delay(10);
digitalWrite(cols[i], HIGH); //write the col high
for(int j = 0; j < 8; j++)
{
pinMode(rows[j], INPUT_PULLDOWN);
delay(10);
keyTable[j][i] = digitalRead(rows[j]);
if(digitalRead(rows[j]) == HIGH && digitalRead(cols[i] == HIGH))// if the current key is pressed
{
Serial.println("Played?");
//Velocity calculation
drum1.noteOn();
}
pinMode(rows[j], INPUT);
}
pinMode(cols[i], INPUT);
}
}