Store › Forums › Audio Hacker › Discussion and Project Ideas › Information about stored data
- This topic has 6 replies, 2 voices, and was last updated 10 years ago by danespcha.
-
AuthorPosts
-
October 21, 2014 at 9:19 am #729danespchaMember
Hello,
I need to know what are the values that are stored in the SRAM, I know that is the voltage, but does the values have any relation with the sound wave?
I’m asking this because I need to use that values to identify steps with a Neural Network, and when I saw the values are always two values changing.
So, there is any way to get the values of the wave or anything like that?Here is my code:
#include
int lectura = 0;
unsigned int sampleRate;
unsigned int playbackBuf = 128;
volatile unsigned int tCycles;
unsigned int passthroughSampleRate;
unsigned int recordingSampleRate;
unsigned int playbackSampleRate;
volatile unsigned int timer1End;
volatile unsigned int timer1Start;
unsigned int readBuf[2];
int currentA0Position;
boolean evenCycle=true;
volatile byte writebuffer;
volatile long address = 0;
volatile long endAddress = 0;
volatile byte chipAddress=0;
volatile unsigned int mode=0;
volatile int aux = 0;
void setup(){
Serial.begin(9600);
sampleRate=18000;
timer1Start = UINT16_MAX-(F_CPU/sampleRate);
AudioHacker.begin();
}
void loop(){
evenCycle=!evenCycle;
if(aux==1){
Serial.println("Grabacion completada");
int x=0;
int y=0;
for(x;x<3;x++){
for(y;yAudioHacker.readSRAMPacked(x,y,readBuf);
Serial.println(readBuf[0]);
Serial.println(readBuf[1]);
}
}
}
}
ISR(TIMER1_OVF_vect){
TCNT1=timer1Start;
byte signal;
if(mode==0){
signal=AudioHacker.readADC();
if(evenCycle){
writebuffer=signal;
}
else{
AudioHacker.writeSRAMPacked(chipAddress,address,writebuffer,signal);
address+=3;
if (address > MAX_ADDR) {
if (chipAddress == 0) {
// proceed to the second SRAM chip
address = 0;
chipAddress = 1;
}
else {
mode=1;
aux=1;
}
}
}
}
if(mode==1){
}
}
October 23, 2014 at 4:52 pm #2078MichaelKeymasterAudio is digitized by sampling a voltage that changes over time. I think you should study up on fundamentals of digitization of analog data. When a varying voltage is given to a speaker, it makes sound.
October 23, 2014 at 7:50 pm #2082danespchaMemberOk, thank you… Is my code correct? I want to record until memory is full and then show the values in serial, is that correct?
October 23, 2014 at 11:16 pm #2083MichaelKeymasterNo, it’s not correct. The first argument for readSRAMPacked is the chip number, and valid values are 0 and 1. You are using values 0, 1, 2.
See the docs here:
https://nootropicdesign.com/audiohacker/Are you sure you want to print out hundreds of thousands of lines of data?
October 24, 2014 at 5:37 am #2086danespchaMemberYes, I’m sure, it’s only a kind of debug, I only want to see if the values are all different between themselves, because now, I only get one or two values, like 5 and 230 that are switching always like 0, 230, 0 230…
When I get all values different I’m going to send them with xbee to the PC and use them in a neural network.October 24, 2014 at 12:14 pm #2090MichaelKeymasterYour code has problems. Are you sampling 8 bit data or 12 bit data? You are reading a 12 bit value from the ADC with readADC() which returns an unsigned int, but you are storing it in a variable that is a byte. This is wrong. Your variables writebuffer and signal should be unsigned int, not byte.
Are you sure you want to pack 2 12-bit values into 3 bytes for storage? Will your neural network software “unpack” these values? Can you change to use 8-bit audio instead because that might be simpler?
PLEASE read the API documentation here https://nootropicdesign.com/audiohacker/
It tells you exactly how to use the ADC, DAC, and SRAM memory.November 1, 2014 at 12:54 am #2096danespchaMemberSolved. Thank you so much, it was the 16 bit encode I didn’t think on decoding it, used the 8 bit record and it works.
I will not disturbe you anymore, thank you again! -
AuthorPosts
- You must be logged in to reply to this topic.