In the old days I was rather a Commodere PC guy, but I know of colleagues of mine that were addicted to the Commodore 64 and knew it inside out. So, here is another project that makes you feel nostalgic:
Sound Interface Device (SID) is a audio format used by the Commodore 64.
To get some SID files, I can recommend The High Voltage SID Collection (HVSC) which is a freeware hobby project that organizes Commodore 64 music into an archive for both musicians and fans alike.
Unfortunately we can not feed SID files incrementally to a codec, so this does not fit with my audio codecs that are used e.g. in the AudioPlayer of the AudioTools library.
Therefore I created a separate project, that provides a dedicated SID stream and a SID player that can play SID from files or from in memory hex dumps on Arduino. The player is based on the AudioPlayer from the Arduino Audio Tools, so you can use different audio sources and audio sinks.
The SID emulation is based on cSID light by Hermit (Mihaly Horvath), (Year 2017).
Arduino Sketch
Here is a simple demo sketch that plays a SID hex file:
#include "AudioTools.h"
#include "SIDStream.h"
#include "AudioLibs/AudioKit.h" // only when using AudioKit
#include "audio/commando.h"
uint16_t sample_rate=32000;
uint8_t channels = 2;
AudioKitStream out; // or replace with other class
SIDStream sid(music_Commando_sid, music_Commando_sid_len);
StreamCopy copier(out, sid);
// Arduino Setup
void setup(void) {
// Open Serial
Serial.begin(115200);
AudioLogger::instance().begin(Serial, AudioLogger::Info);
// start I2S
Serial.println("starting I2S...");
auto config = out.defaultConfig(TX_MODE);
config.sample_rate = sample_rate;
config.channels = channels;
config.bits_per_sample = 16;
out.begin(config);
// Setup SID
auto scfg = sid.defaultConfig();
scfg.copyFrom(config);
sid.begin(scfg);
//sid.setSID(music_Commando_sid, music_Commando_sid_len);
}
// Arduino loop - copy sound to out
void loop() {
copier.copy();
}
I have used an AudioKit to test this sketch.
The project and further examples can be found on Github.
The project supports cmake, so you can also build and run it on the desktop!
Final Comments
If your microcontroller does not support I2S you can use the following output classes instead:
- I2SStream
- AnalogAudioStream
- PWMAudioOutput
- VS1053Stream
2 Comments
Gianluca · 4. October 2023 at 9:11
Using a ESP32 based board to play audio SID files. I have the DAC IO25 ready to play music at audio speaker level. What are the mandatory steps to run the code using the Digital to Analog converter line on DAC IO25? Please help.
pschatzmann · 4. October 2023 at 12:21
As indicated in the blog you would just replace the output class: If you want to use the internal DAC you would use the AnalogAudioStream.
I recommend you to read the documentation of the AudioTools…