Mini Record Player – Ongoing Project

This is my little invention I have been working on. It’s an alternative record player.
Albums are great because you can enjoy the covers, are forced to listen to the whole thing and the ritualistic tactile process of finding an album and then playing is neat. They suck because they cost a lot and some albums are impossible to get.
My little invention solves that as it only costs the print out of the album on to photo paper (20c) and I can load up unofficial bootlegs, my own mixes and even internet radio.
It’s a raspberry pi reading qr codes that then plays a needle drop sound effect and then the matching folder’s contents. The next phase will be in making it look better, and a button to skip a track. And add a battery to make it portable.

The current code:

import cv2
import os
import time
import subprocess
# set up camera object called Cap which we will use to find OpenCV
cap = cv2.VideoCapture(0)
# QR code detection Method
detector = cv2.QRCodeDetector()
lastalbum = 'empty'
sudoPassword = ' '
light0on = 'echo default-on | sudo tee /sys/class/leds/led0/trigger'
light0off = 'echo none | sudo tee /sys/class/leds/led0/trigger'
light1on = 'echo default-on | sudo tee /sys/class/leds/led1/trigger'
light1off = 'echo none | sudo tee /sys/class/leds/led1/trigger'
os.system("killall " "vlc")
#This creates an Infinite loop to keep the camera searching for data at all times
while True:
# Below is the method to get a image of the QR code
_, img = cap.read()
# Read the QR code by detecting the bounding box coords and decoding the hidden QR data
data, bbox, _ = detector.detectAndDecode(img)
# Blue Box around our Data. This will draw one, and then Write the Data along with the top
if(bbox is not None):
for i in range(len(bbox)):
cv2.line(img, tuple(bbox[i][0]), tuple(bbox[(i+1) % len(bbox)][0]), color=(255,
0, 0), thickness=2)
cv2.putText(img, data, (int(bbox[0][0][0]), int(bbox[0][0][1]) - 10), cv2.FONT_HERSHEY_SIMPLEX,
1, (255, 250, 120), 2)
if data:
if data == lastalbum:
print ("A repeat Scan")
else:
os.system("killall " "vlc")
p = os.system('echo %s|sudo -S %s' % (sudoPassword, light0on)) # On
p = os.system('echo %s|sudo -S %s' % (sudoPassword, light1on)) # On
if data[0:3] == '_s_':
os.popen("cvlc --novideo --random ~/Music/" + data + "/ >/dev/null 2>&1")
print("record player plays " + data + " shuffled")
else:
os.popen("cvlc --novideo ~/Music/needledrop.flac ~/Music/" + data + "/ >/dev/null 2>&1")
print("record player plays " + data + " in order")
time.sleep(10)
p = os.system('echo %s|sudo -S %s' % (sudoPassword, light0off)) # Off
p = os.system('echo %s|sudo -S %s' % (sudoPassword, light1off)) # Off
lastalbum = data
# Below will display the live camera feed to the Desktop on Raspberry Pi OS preview
cv2.imshow("code detector", img)
# When the code is stopped the below closes all the applications/windows that the above has created
cap.release()
cv2.destroyAllWindows()

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.