Information about stored data

Store Forums Audio Hacker Discussion and Project Ideas Information about stored data

This topic contains 6 replies, has 2 voices, and was last updated by  danespcha 4 years, 7 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #729

    danespcha
    Member

    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;y AudioHacker.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){
    }
    }


    #2078

    Michael
    Keymaster

    Audio 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.

    #2082

    danespcha
    Member

    Ok, thank you… Is my code correct? I want to record until memory is full and then show the values in serial, is that correct?

    #2083

    Michael
    Keymaster

    No, 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?

    #2086

    danespcha
    Member

    Yes, 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.

    #2090

    Michael
    Keymaster

    Your 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.

    #2096

    danespcha
    Member

    Solved. 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!

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.