GUI Music Player

Team Members

  • Etitoghene Ovhori
  • Russell Dawkins
  • Obinna Onyeije
  • Dianna King

Project Description

A SparkFun sd card was used in this project to store the songs on the mbed device. The wav files were played through a speaker that was also connected to the mbed device. A potentiometer was connected to the speaker to control its volume. On the raspberry pi 3 side, a large touch pad was used with the device. The songs were played through selecting them on this large touch pad. An additional LED was wired to the mbed, which alteranted color as different songs were played. A 5V 2A source was connected to the power rail on the breadboard and another was connected to the pi 3. The songs were down-sampled to 8khz in order for them to be played clearly through the speaker.

The non-mbed side of the project required us to create a GUI in python through which the media would be selected. Image files were correctly linked to the appopriate media files using guizero.

SD Card Pinout

500

Class D Amp Pinout

500

Potentiometer Pinout

https://os.mbed.com/components/Potentiometer/

Speaker Pinout

https://os.mbed.com/users/4180_1/notebook/using-a-speaker-for-audio-output/

Wiring Schematic

1000

This is the wiring diagram that represents how the components were connected

code written to read in signal from pi serial port and play music

#include "mbed.h"
#include "SDFileSystem.h"
#include "wave_player.h"

SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card

AnalogOut DACout(p18);

wave_player waver(&DACout);
//Pi mbed USB Slave function
// connect mbed to Pi USB
RawSerial  pi(USBTX, USBRX);
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
DigitalOut led4(LED4);

FILE *wave_file1;
FILE *wave_file2;
FILE *wave_file3;
FILE *wave_file4;
char temp = '0';

void dev_recv()
{
    while(pi.readable()) {
        temp = pi.getc();
        printf( &temp);
    }
}
int main()
{
  pi.baud(9600);
  pi.attach(&dev_recv, Serial::RxIrq);
    while(1) {
         pi.putc(temp);
      char *   xyz = &temp;
        if ( xyz[0] == 49) {
            led1 = 1;
            wave_file1 =fopen("/sd/mydir/got.wav","r");
            waver.play(wave_file1);
            wait(20);
            fclose(wave_file1);
        }
       else if ( xyz[0] == 50) {
            led2 = 1;
            wave_file2 =fopen("/sd/mydir/m1.wav","r");
            waver.play(wave_file2);
            wait(20);
            fclose(wave_file2);
        }
        else if ( xyz[0] == 51) {
            led3 = 1;
            wave_file3 =fopen("/sd/mydir/poke.wav","r");
            waver.play(wave_file3);
            wait(20);
            fclose(wave_file3);
        }
        else if ( xyz[0] == 52) {
            led4 = 1;
            wave_file4 =fopen("/sd/mydir/proud.wav","r");
            waver.play(wave_file4);
            wait(20);
            fclose(wave_file4);
        }
        sleep();
    }
}


This is a link to the code that was developed for the GUI using pi zero. A separate file was created for the music picker class.

https://github.gatech.edu/oonyeije3/ECE-4180-S19-Design-Project/tree/master/serialBowl

Music picker class in python

music picker class in python

import serial
import time

class musicPick(object):
	
    def __init__(self):
        self.__serialPort = ''
        self.__val = ''
	
    def setSerialPort(self,port):
        self.__serialPort = port

    def sendSignal(self,val):
        ser = serial.Serial(self.__serialPort)
        print(ser) #Checks serial port
        ser.write(val)

Python code to represent song objects

song objects

import musicPick as mP
import serial
import time
from guizero import App, Text, PushButton , Picture, Window

app = App(layout = "grid") 

def say_val():
    name  = Text (app, text = "Game of Thrones Theme Song", grid = [1, 0 ])
    picture = Picture(app, image = "w4.png", grid = [0,5] )
    val = 1
    musPick.sendSignal(str(val).encode('utf-8'))
    

def say_val2():
    name  = Text (app, text = "Super Mario Brothers", grid = [1, 1 ])
    picture = Picture(app, image = "m1.png", grid = [0,5] )
    val = 2
    musPick.sendSignal(str(val).encode('utf-8'))

def say_val3():
    name  = Text (app, text = "Pokemon", grid = [1, 2 ])
    picture = Picture(app, image = "poke.gif", grid = [0,5] )
    val = 3
    musPick.sendSignal(str(val).encode('utf-8'))

def say_val4():
    name  = Text (app, text = "The Proud Family", grid = [1, 3 ])
    picture = Picture(app, image = "proud.gif", grid = [0,5] )
    val = 4
    musPick.sendSignal(str(val).encode('utf-8'))    

serialPort = '/dev/ttyACM0'
musPick = mP.musicPick()

musPick.setSerialPort(serialPort)
text = Text(app)
button1 = PushButton(app, text = "HBO", grid = [0,0], command=say_val)
button2 = PushButton(app, text = "Nintendo", grid = [0,1], command=say_val2)
button3 = PushButton(app, text = "Cartoon", grid = [0,2], command=say_val3)
button4 = PushButton(app, text = "Disney", grid = [0,3], command=say_val4)
app.display()


Below is a photo showing a running demo with components connected

700

Below is a video that shows a full demo of the project .


Please log in to post comments.