Playing sound files from external EEPROM

I’m trying to play a sound file that has been loaded onto one of these EEPROM modules. I’ve been using this library to play short sound files directly off the arduino’s EEPROM, but want to play files directly off of an external EEPROM instead.

I’m trying the following, which uses the EEPROM sample code from spark fun , but I’m not getting anything but noise.

#include <Wire.h>

#include <PCM.h>

#define EEPROM_ADR 0x54

void setup()
{

//Start the I2C Library
  Wire.begin();
  Wire.setClock(400000); 

//Start the serial port
  Serial.begin(115200);

  //Output raw bytes to terminal
  //In this case we're going to read all of the bytes
  //which is 32000, or in hex, 0x7D00
  for (long x = 0 ; x < 0x7D00 ; x++) //Read all 131,071 bytes from EERPOM
  {
    byte val = readEEPROM(x);
  //  Serial.write(val);
    startPlayback(val, sizeof(val));


}
}

void loop()
{




}





byte readEEPROM(long eeaddress)
{
  Wire.beginTransmission(EEPROM_ADR);

  Wire.write((int)(eeaddress >> 8)); // MSB
  Wire.write((int)(eeaddress & 0xFF)); // LSB
  Wire.endTransmission();

  Wire.requestFrom(EEPROM_ADR, 1);

  byte rdata = 0xFF;
  if (Wire.available()) rdata = Wire.read();
  return rdata;
}

What do I need to change in order to make this work?

You need a better EEPROM, you can’t access that as fast as you need the samples. One way is to transfer the sample into SRAM first and then play from that.

Go with an SD card. Can capture samples at CD quality rate (mono 16-bit 44100 samples) with an external ADC chip, and play back with an external DAC.
See this thread:

I was wondering if access speed might be the issue. I’m trying to avoid using an SD Card. Is there EEPROM that would transfer data fast enough?

Since speed is the issue, I’m trying to copy sounds from the external EEPROM to built in memory, and I’m trying this but not getting anything to print out.

//Include the Wire I2C Library
#include <Wire.h>

#include <PCM.h>

#define EEPROM_ADR 0x54
char example_string[] = "~New eeprom string";

const int eeprom_size = 500; // values saved in eeprom should never exceed 500 bytes
char eeprom_buffer[eeprom_size];

void setup()
{

//Start the I2C Library
  Wire.begin();
  Wire.setClock(400000); 

//Start the serial port
  Serial.begin(115200);

 const int S = 1; 
  byte buffer[S];


  
  for (long x = 0 ; x < 0x7D00  ; x++) //Read all 131,071 bytes from EERPOM
  {
eeprom_buffer[x] = readEEPROM(x);


}
 Serial.print(eeprom_buffer);
}

void loop()
{




}

byte readEEPROM(long eeaddress)
{
  Wire.beginTransmission(EEPROM_ADR);

  Wire.write((int)(eeaddress >> 8)); // MSB
  Wire.write((int)(eeaddress & 0xFF)); // LSB
  Wire.endTransmission();

  Wire.requestFrom(EEPROM_ADR, 1);

  byte rdata = 0xFF;
  if (Wire.available()) rdata = Wire.read();
  return rdata;
}

There are fast SPI EEPROMs. FRAM would be better - SRAM access speed, EEPROM non-volatility.
What quality level are you after? # of bits/sample, # of samples/second. And what length of sound?

I'm trying to copy sounds from the external EEPROM to built in memory,

This is because in an Arduino UNO you only have enough internal memory for about a quarter of a second of sound.

None of my sounds are more than 450 bytes each (I noticed in the sketch I posted, I originally had my buffer set to 1500 rather than 500, which I've corrected). They are all 8 bit 8 mHz files. I tried using a FRAM module instead, but speed still seems to be an issue.

nonlinearmind:
None of my sounds are more than 450 bytes each They are all 8 bit 8 mHz files.

So assuming that you actually mean a sample rate of 8KHz and not 8MHz then the sounds last 0.05625 seconds?