PDA

View Full Version : Technology Arduino to play the audio file in Zx Spectrum



Tiago
29th October 2015, 10:52
Hi,
some time ago i remember someone here to talk about a circuit to read the audio from a tape into the ZX Spectrum
Well i am trying to do something similar:
I bought an small cricuit that has a sdcard slot and a 2.5 output jack. It reads mp3/wav files. The price is +/- 5 euros.
I am using the Arduino, i am using the UNO 3, but it can be done with the smaller one, the Nano. I connect the mp3 board to the Arduino, put a mp3 in the scard, and with some wire and programming i was able to play the mp3 and listen in headphones. It needs a 5v but with the Arduino nano it can be done with 3v. I will now put a LCD screen to see the name of the files in the sdcard, and some buttons to choose the file and play it.
Putting the ZX game file in mp3 or wav and connect the Arduino into the ZX, i think i can create a player for the ZX with a size smaller then a credit card. Total production cost should be around 20 euros.

Arduino nano +/- 6 euros
LCD +/- 7 euros
MP3 card +/- 5 euros
Buttons +/- 2 euros
wire+solder +/- 50 cents

The lcd needs a lot of iron solder to put all cables connected to the arduino.
The game will take the same time to load, but you can have all games in the sdcard. It is the same concept to the Amiga HXC, but simple to do it.
I am sure someone did this before, but it's quite fun to do it yourself.

Buleste
30th October 2015, 09:24
A friend and I made something for most 8-bits that use a standard tape deck and added motor control to it. We never got anyone with a Spectrum to test it though.

I'd love to see pictures and a link to the mp3/sdcard/audio output as that could make a lot of difference to the project with playback frequencies.

http://arduitapemarkii.blogspot.co.uk/

Tiago
30th October 2015, 12:25
Hi Buleste, the circuit is this one:
http://www.dx.com/p/uart-control-serial-mp3-music-player-module-for-arduino-avr-arm-pic-blue-silver-342439#.VjNvkuztlHw

Buleste
30th October 2015, 14:50
Hi Buleste, the circuit is this one:
http://www.dx.com/p/uart-control-serial-mp3-music-player-module-for-arduino-avr-arm-pic-blue-silver-342439#.VjNvkuztlHw

Thanks for that I am seriously going to have to build another version of the Arduitape

Tiago
30th October 2015, 15:10
The code is not that difficult. I was able to put it to play an mp3 and could do a play/pause with a input. It is easy to put a potentiometer to control volume. And 3 or 4 buttons to choose a file to play from the sdcard. this last part i need to read more about it.

check the base code:

/***********************************************************/
//Demo for the Serial MP3 Player by Catalex
//Hardware: Serial MP3 Player *1
//Board: Arduino UNO R3
//IDE: Arduino-1.0
//Function: To play the first song in the micro sd card.
//Store: http://www.aliexpress.com/store/1199788
// http://www.dx.com/
#include <SoftwareSerial.h>

#define ARDUINO_RX 5//should connect to TX of the Serial MP3 Player module
#define ARDUINO_TX 6//connect to RX of the module
SoftwareSerial mySerial(ARDUINO_RX, ARDUINO_TX);

static int8_t Send_buf[8] = {0} ;

#define CMD_PLAY_W_INDEX 0X03
#define CMD_SET_VOLUME 0X06
#define CMD_SEL_DEV 0X09
#define DEV_TF 0X02
#define CMD_PLAY 0X0D
#define CMD_PAUSE 0X0E
#define CMD_SINGLE_CYCLE 0X19
#define SINGLE_CYCLE_ON 0X00
#define SINGLE_CYCLE_OFF 0X01
#define CMD_PLAY_W_VOL 0X22

void setup()
{
mySerial.begin(9600);
delay(500);//Wait chip initialization is complete
sendCommand(CMD_SEL_DEV, DEV_TF);//select the TF card
delay(200);//wait for 200ms
sendCommand(CMD_PLAY_W_VOL, 0X0F01);//play the first song with volume 15 class
}
void loop()
{

}

void sendCommand(int8_t command, int16_t dat)
{
delay(20);
Send_buf[0] = 0x7e; //starting byte
Send_buf[1] = 0xff; //version
Send_buf[2] = 0x06; //the number of bytes of the command without starting byte and ending byte
Send_buf[3] = command; //
Send_buf[4] = 0x00;//0x00 = no feedback, 0x01 = feedback
Send_buf[5] = (int8_t)(dat >> 8);//datah
Send_buf[6] = (int8_t)(dat); //datal
Send_buf[7] = 0xef; //ending byte
for(uint8_t i=0; i<8; i++)//
{
mySerial.write(Send_buf[i]) ;
}
}

Buleste
30th October 2015, 15:45
Did you have to rename the mp3 files to fit with the code?

Tiago
30th October 2015, 16:04
I just rename to avoid strange characters. Some readers tend to not recognize strange ascii symbols. But it can read long file names. But you can have any name in the mp3.
My test was with a hangar18_rust_in_peace_megadeth.mp3 or something like this. but it had same %$# symbols in the file name, so i remove those.


But:
- it has to be bellow 44kbs
- the sdcard must be bellow 2GB
- the scdard bus be FAT or FAT32

There are other cards that can read bigger cards and mp3 at 192kbs or higher but they are more expensive. For what i need i this one is enough.

Buleste
30th October 2015, 16:17
Just had a look and it can handle Micro SDHC cards <= 16GB so that's that one and as most tap, cas, etc files were originally recorded at 41MHZ that's fine.

Just getting my head around the controls for buttons. Did the LCD display the LFN or have you not got that far?

Tiago
2nd November 2015, 12:06
Did the LCD display the LFN or have you not got that far?
LFN? What is that?

Buleste
2nd November 2015, 15:00
LongFileNames rather than being stuck with the usual 8+3.

I've ordered a couple along with Nanos and 1602's and made a proto board. I'm going to see which MSX games I can find which don't need Motor control and test it at the normal Arduitape frequency and then the standard cas2wav frequency to see how well the Wav playback is with the computer and then it's a case of rewriting the Arduitape software first to work with .WAV files and then to see if it will work converting as well.

Tiago
3rd November 2015, 10:41
I didn't put the LCD yet. I put a LCD but for other project, i did a clock with a RTC Texas instrument chip. I put the data/time/temperature on the LCD, but it was a fixed character set.

Buleste
3rd November 2015, 10:49
I'm not sure about how to hook up the LCD just yet. Going through as many samples as I can find as to how others have done it so that I have a clue.

Tiago
3rd November 2015, 12:18
Read my article. It's in Portuguese but you can translate it in google.
You have a schematics about it. I can send you the code to put a hello word in the screen

http://revistapushstart.com/2013/06/29/arduino-criar-um-relogio/

Buleste
3rd November 2015, 17:31
Oh. I know how to get stuff to display on the screen but it's how to get the screen to display filenames on the sdcard with this particular module that is what I'm looking into now. If you look at the blog I've already built and programmed with a separate SD card module but this one looks like it requires different programming.

Tiago
4th November 2015, 10:50
hum ok. I didn't get to that point yet. Not enough time. I will try to do it on next weeks. Let you now my progress.

But your problem is how to display the file names on LCD? Or how to retrieve file names from Sdcard?
Putting text on screen is easy, but my lcd is 16x2 characteres, so if the file name is 40 characters long, it must scroll.
Getting the file name from Sdcard... i don't have any clue, i am using a simple code to read the MP3 from the card, but the code grabs the first file in it. I have to search a way to list all files and choose one.

Buleste
4th November 2015, 16:09
I know how to do it on my old system but it's getting the scroll and displaying the full filename on a 1602. I'll sort it out soon I'm sure.

Buleste
21st November 2015, 15:53
Finally got my kit yesterday. Wav playback is only for files that are 44100 Hz and whilst MP3 files MAY be audible to the human ear it's whether the computer recognises them that's the issue. So far I've not managed to get an MP3 to work on my MSX however after much trial and error to get the right frequency I did manage to find the right one. Now I need to add Motor Control to the Nano so that there are pauses when the computer requests pauses.

Buleste
24th November 2015, 12:11
Okay. Motor Control works and after translating the datasheet for the YX5300 (which is the chip onboard) I've sound that the supported sampling rate (KHZ):8/11.025/12/16/22.05/24/32/44.1/48. Struggling to find out how to read filenames and print them on LCD so far and getting no support from Arduino forums.

Tiago
24th November 2015, 17:03
Does that board not go higher then 48khz ? You said before that it does 44.1
If you could do 48khz... did you try higher then that?

Buleste
25th November 2015, 10:02
Yes. it does play 48kHz. I have also found out the board doesn't allow the reading of filenames so unless you know the track order on the sd card it's nigh on impossible to select the right game.

Tiago
25th November 2015, 17:25
Yes. it does play 48kHz. I have also found out the board doesn't allow the reading of filenames so unless you know the track order on the sd card it's nigh on impossible to select the right game.

I think my board is similar to that one... i didn't had the time yet to look but i guess it's same.

Buleste
26th November 2015, 09:34
The Catalex serial MP3 Player is good but the lack of ability to read filenames and display them means it's useless to me.

I have found the STM32F4 Discovery however which really does look like it has a lot of potential.