There are many existing portable MP3 players. But not many have the flexibility to be customized to operate with additional devices such as flashy lights and animated decors.
I wanted a cool Jukebox device to automatically play a batch of favorite songs with a simple on/off switch. Without having to search menu options, setting up macros, and change play mode. This will also make it easy to turn on with voice operated peripheral switches (such as Amazon Alexa or Google Home). No more expense of registering and uploading to online song storage just to play your own favorite songs.
I also want pulsing lights and moving decor that add visual to the music like a party disco room.
On rare occasions, I need a quality portable recorder that can record group conversations for video editing. With proper time stamp for later sound and video synchronization.
Using Sony Spresense, a small, single board can provide all the functionality. Without additional boards and devices.
- Automatically plays random songs on startup from music directory in SD card.
- Colored light changes responds to music.
- Battery operated with USB charging
- External connectors for optional animatronics to animate to the decoded wave of the playing music.
- Capable of portable MP3 recorder. with location time stamp.
The Sony Spresense development board is a versatile, compact development board. I'm using following features for this project.
- GPS to obtain clock and time. -
- MP3 Player to play back files from SD card.
- Servo and PWM to control external motors to operate moving toys and decors.
Follow these instructions https://developer.sony.com/develop/spresense/developer-tools/get-started-using-arduino-ide/set-up-the-arduino-ide to use with Arduino IDE.
Install Audio CODEC Library
After setup. Install the sample MP3 Decoder on to the SD card. These will be referenced by music player code sketch in the firmware.
- File>Examples>(Examples For Spresense) Audio>dsp_installer>mp3_dec_installer
- Compile and upload sketch
- Open Serial Monitor (Tools > Serial Monitor)
- Select option to write MP3 decoder on SD card
- Repeat above step to add mp3_enc_installer for optimal MP3 Encoder for the mic function.
Upload Music Player Sketch
- Create a new Sketch ( File> New)
- Paste in code from MP3 Jukebox from sketch
- Compile and upload sketch
Operations
- Create a folder named "MUSIC" on the root of SD card.
- Copy your favorite mp3 song file inside a "MUSIC" folder
- Rename each songs file as music_xx.mp3 in sequence. ( Starting with index 0, and no missing number in between, up to 100 songs)
SD CARD > MUSIC
music_00.mp3
music_01.mp3
music_02.mp3
Songs will be randomly played back on power on.
Optional Configurations
If you have added the peripheral components, you can copy in the code for each of the components and uncomment the configuration section in MP3Jukebox Sketch by removing the // in front of each #define statement
/* Peripheral configuration */
#define GPS_TIME
#define SERVO
#define RGB_LCD
#define ROTARY_ENCODER
GPS_TIME
This is helpful to create more randomized song playlist upon power on. Experimented with reading analog pins for random number seed only generate few variation of repeated sequences. Using delay time to satellite acquisition provides more random factors.
SERVO
Configure your own by changing the degree, and timing of rotation for the servo motor.
RGB_LCD
Configure color and brightness to flash based on amplitude sound wave
ROTERY_ENCODER
Enable Skipping Songs, play or pause songs, recordings.
Battery and ChargingFor portable power, I used a 3.7V flat Lithium battery from Galaxy phone. The thin battery snug fits between the pin headers of the extension board.
Any external 5V portable battery pack can also power the board's via microUSB port.. I want to make it smaller with DIY battery pack.
- Solder the battery terminal to a USB single cell charging chip.
- Added a power on/off toggle switch.
- Soldered connections to power 2 micro servo.
- Add a thin 2 pin power connector to Sony Spresense. external DC connector.
Servo draws power from battery to not overload the Spresense board. ( max current of 500 mA.)
Here are attachments I can add to the base board depend on situational usage. Playing music at home party, music on the go, or recording.
RGB LCD Screen
I used this as a convenient way to operate 5V colored lights. Light will change in color and brightness based on wave form of the played back music. It can be programmed to display song status, time, operation modes.. etc.
Rotary Switch with Push Button
I can switch and skip songs by rotating the switch. Play and pause songs.
Press hold the button while power up to switch to record mode.
Microphone
I used 2 electret microphone as left and right channel for the voice input recording.
I soldered 2.2K Ohm resistor to the wires to the microphone.
Servo Motors
These can be attached control any thing mechanical to animate objects. I'm using one to animate the teddy. The spare one to attach to LED light switch knob to control powered LED lights ( check out my Rotational Magnetic Multi Switch project.)
For the dancing decor I used a plush teddy bear that bends easily. To animated it with a string like marionette puppet.
- Tied down legs to a platform with a rubber band.. Platform can be a plastic cover, card board, or slab of decor stone.
- Affix a white sewing string though the back where scarf hides the seam for control.
- .Create extension servo arm to increase the length of displacement to the string. Staple pin through the body of plastic tooth floss. tighten the pin to servo mount holes.
Enclosure
Found a. used a credit card size box from pins. It snugly fit both servo motors, battery and Spresense inside.
Board offers lots of functionality. Initially testing individual sample sketch from Spresense SDK to work with top level audio class is straightforward. Board sounds great for Hi-fidelity audio.
However, I encountered many issues while testing the API for custom implementations not covered by examples. Such as combining various object level API example for recording, mic pass through, and file playback sketches.
I had to switch to flexible Object level API for song playback to resolve loud popping noise when changing songs playback.
I also struggled with error codes, timing issues with the DSP processor and crashing errors when interrupted with switches.
For future projects using Audio, I'll need to understand the detail memory pool allocation parameter better to continue further.
Comments