Raspberry Pi Snowman (Help)
Raspberry Pi Snowman (Help)
I was thinking of doing a cute lil project as a decoration for Christmas coming up.
I'm planning to put something on the back of a stuffed snowman or something, and make it so that it's holding a small trumpet.
The idea is that you have to press a tactile switch on the trumpet to make it start playing music, but I'm not too sure on how I can get this done.
I'm not going to mess around with coding, as I suck at it, so my plan is to just have a similar setup as the mintypi with the small usb dac. When you press the button, the circuit will be completed and the sound gets played, but when you let go, it stops. The problem is, how am I going to get an audio track to be played over and over again over usb?
Can anyone tell me?
I'm planning to put something on the back of a stuffed snowman or something, and make it so that it's holding a small trumpet.
The idea is that you have to press a tactile switch on the trumpet to make it start playing music, but I'm not too sure on how I can get this done.
I'm not going to mess around with coding, as I suck at it, so my plan is to just have a similar setup as the mintypi with the small usb dac. When you press the button, the circuit will be completed and the sound gets played, but when you let go, it stops. The problem is, how am I going to get an audio track to be played over and over again over usb?
Can anyone tell me?
- YaYa
- Posts: 1719
- Joined: Mon Jun 26, 2017 12:42 pm
- Location: brittany - France
- Has thanked: 871 times
- Been thanked: 689 times
- Contact:
Re: Raspberry Pi Snowman (Help)
Unfortunately, you’ll still need coding for this.
You must create a little script telling the system to play an audio file as soon as the system is loaded and repeat it for ever.
I don’t know which software or binary you can use, i think omxplayer can do the trick as he plays video also.
Have a read here
https://www.raspberrypi.org/documentation/usage/audio/
There should be an option to tell omxplayer to loop once finished playing the file
A quick google
https://gist.github.com/cpmpercussion/6 ... 950e6bcd13
And
https://www.raspberrypi.org/forums/view ... hp?t=10218
You must create a little script telling the system to play an audio file as soon as the system is loaded and repeat it for ever.
I don’t know which software or binary you can use, i think omxplayer can do the trick as he plays video also.
Have a read here
https://www.raspberrypi.org/documentation/usage/audio/
There should be an option to tell omxplayer to loop once finished playing the file
A quick google
https://gist.github.com/cpmpercussion/6 ... 950e6bcd13
And
https://www.raspberrypi.org/forums/view ... hp?t=10218
- moooarcuuuus
- Posts: 232
- Joined: Tue Jul 04, 2017 1:28 am
- Has thanked: 2 times
- Been thanked: 94 times
Re: Raspberry Pi Snowman (Help)
Let it play in a endless loop and control the volume. Start with mpeg123 as a cronjob and "amixer set Master 0%" is a simple bash tool. Or kill mpeg123 and start new.
Raspi is overkill. If you use a cheap pro-mini arduino there is no boot time.
Raspi is overkill. If you use a cheap pro-mini arduino there is no boot time.
Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep, Eat, Sleep... Game Over
Re: Raspberry Pi Snowman (Help)
Whenever I see someone say 'type this command line in', I always get confused:
Should I type the code into the config.txt file? ssh it into the pi?
When wermy made his halloween pumpkin video, he said something about a python script, what did he mean?
- YaYa
- Posts: 1719
- Joined: Mon Jun 26, 2017 12:42 pm
- Location: brittany - France
- Has thanked: 871 times
- Been thanked: 689 times
- Contact:
Re: Raspberry Pi Snowman (Help)
A command is an order that you give to the Pi via his command line. Either from the console on the device itself which assume a connected keyboard and screen, either via a ssh console.
A python script is a piece of code written in python, a powerful programming language.
The piece of code result in the creation of a file that you make executable. You can then launch it via a command like a program (infact, it is a program) or you can launch it automatically when the system is loading.
To do this you have several methods. You can edit configuration files and add some text to tell the system what to do and when to do.
This text can be a command, or a piece of code
A python script is a piece of code written in python, a powerful programming language.
The piece of code result in the creation of a file that you make executable. You can then launch it via a command like a program (infact, it is a program) or you can launch it automatically when the system is loading.
To do this you have several methods. You can edit configuration files and add some text to tell the system what to do and when to do.
This text can be a command, or a piece of code
- wermy
- Site Admin
- Posts: 1346
- Joined: Tue May 03, 2016 8:51 pm
- Has thanked: 620 times
- Been thanked: 1322 times
- Contact:
Re: Raspberry Pi Snowman (Help)
You can do this with an arduino, do a google for playing a wav file - it's not terribly difficult (and I've done it in a few projects). If a raspi is all you have on hand, though, I'd go the python route. That's become my preferred method for detecting and reacting to button/GPIO input and doing a thing based on that. Very easy to run arbitrary commands with that too (so you could load up whatever sound player program you wanted).
Re: Raspberry Pi Snowman (Help)
I did some research, and I think I can use Omxplayer to do this, but how can you make it so it plays over usb audio (similar to the mintypi)?
If you change the config file, there is an option to use the headphone jack (local) or hdmi (hdmi), so how do I use it over usb? Also, how do I get a speaker playing through the headphone jack instead of having it play over the headphones?
Thanks for the help!
- wermy
- Site Admin
- Posts: 1346
- Joined: Tue May 03, 2016 8:51 pm
- Has thanked: 620 times
- Been thanked: 1322 times
- Contact:
Re: Raspberry Pi Snowman (Help)
There is a parameter you can pass to omxplayer to tell it where to output sound. On mintyPi for the splash screen this works:Pentium wrote: ↑Thu Dec 21, 2017 9:14 amI did some research, and I think I can use Omxplayer to do this, but how can you make it so it plays over usb audio (similar to the mintypi)?
If you change the config file, there is an option to use the headphone jack (local) or hdmi (hdmi), so how do I use it over usb? Also, how do I get a speaker playing through the headphone jack instead of having it play over the headphones?
Thanks for the help!
Code: Select all
omxplayer -o alsa -b --layer 10000 "/home/pi/mintyPi/minty-splash.mp4"
Re: Raspberry Pi Snowman (Help)
So if I use this string of code, the audio will output on the USB sound card?wermy wrote: ↑Thu Dec 21, 2017 9:23 am
There is a parameter you can pass to omxplayer to tell it where to output sound. On mintyPi for the splash screen this works:You shouldn't need the layer parameter, though.Code: Select all
omxplayer -o alsa -b --layer 10000 "/home/pi/mintyPi/minty-splash.mp4"
- wermy
- Site Admin
- Posts: 1346
- Joined: Tue May 03, 2016 8:51 pm
- Has thanked: 620 times
- Been thanked: 1322 times
- Contact:
Re: Raspberry Pi Snowman (Help)
Assuming the sound card is set up correctly, yes. As I said that's what I used in the mintyPi for the splash screen, and it uses a usb sound card.
Who is online
Users browsing this forum: No registered users and 1 guest