Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
For a university project I am working with Gigabyte & Linux which I am not used to at all.
I connected several sensors to arduino, and based on the sensor data I have to play several audio/video files.
I have plugged in a "phone", which is the exact same as normal earbuds, and connected in an HDMI cable with a screen + sound boxes to the Gigabyte as well.
The problem is that, with some particular sensor values, I would like to use the phone as audio output, where for other sensor values the sound should go through the boxes.
Being an absolute beginner with linux, I have NO IDEA how I can achieve this, but it's a MUST for my project.
I really hope there is anyone with some piece of advice for me.
Any comment is welcome! Thanks in advance!
For a university project I am working with Gigabyte & Linux which I am not used to at all.
I connected several sensors to arduino, and based on the sensor data I have to play several audio/video files.
I have plugged in a "phone", which is the exact same as normal earbuds, and connected in an HDMI cable with a screen + sound boxes to the Gigabyte as well.
The problem is that, with some particular sensor values, I would like to use the phone as audio output, where for other sensor values the sound should go through the boxes.
Being an absolute beginner with linux, I have NO IDEA how I can achieve this, but it's a MUST for my project.
I really hope there is anyone with some piece of advice for me.
Any comment is welcome! Thanks in advance!
Hi kmvtxx and welcome to LQ.
Well, how did you come upon this project? Is it assigned "as is" or is it something you selected?
Because my point is that if it is an assigned project, then it should be guided somewhat by your instructor. And even if it is self-chosen, since you're studying Linux, you have an instructor and they should at least give you some guidance as to what is reasonable for you to tackle.
My impression is that you need to have some of these various sound files play, depending on the inputs from any given sensor.
What's missing is the information as to how these sensors are hooked up to your board. Serial/UART, I2C, SPI, GPIO, or other. At the simplest level, for a beginner, each sensor should be on some sort of sample board and hooked up using a very normal interface, such as USB and then use maybe USB serial to communicate. Next it would have a command set for that serial interface. At the more complex levels, these would need to be custom wired to specific interfaces, such as the SPI bus, or the I2C bus, and there are probably more than one of each of these buses or the pins might be dual use to be capable of both types of serial communications.
Perhaps you can share the history of what led to this project selection, and then discuss how these sensors are physically hooked up and how you expect to talk to them via software.
Well, how did you come upon this project? Is it assigned "as is" or is it something you selected?
Because my point is that if it is an assigned project, then it should be guided somewhat by your instructor. And even if it is self-chosen, since you're studying Linux, you have an instructor and they should at least give you some guidance as to what is reasonable for you to tackle.
My impression is that you need to have some of these various sound files play, depending on the inputs from any given sensor.
What's missing is the information as to how these sensors are hooked up to your board. Serial/UART, I2C, SPI, GPIO, or other. At the simplest level, for a beginner, each sensor should be on some sort of sample board and hooked up using a very normal interface, such as USB and then use maybe USB serial to communicate. Next it would have a command set for that serial interface. At the more complex levels, these would need to be custom wired to specific interfaces, such as the SPI bus, or the I2C bus, and there are probably more than one of each of these buses or the pins might be dual use to be capable of both types of serial communications.
Perhaps you can share the history of what led to this project selection, and then discuss how these sensors are physically hooked up and how you expect to talk to them via software.
Thank you for your comment.
I am not sure if I will be able to answer your questions.
First of all, the setup is my own idea/initiative.
The person who could advice me about linux is currently unavailable.
I do have experience with Arduino and Processing. I hooked up the sensors via arduino, for example a proximity sensor.
If the sensor values pass the set threshold, Processing (processing.org) get's notified and plays a certain sound or video. As far as I'm concerned, processing has no abilities to automatically choose an audio output.
The communication between Arduino and Processing is serial.
When another sensor, for example a PIR movement sensor, senses movement and becomes HIGH, again processing will be notified, and the other audio output should be used to get the effect of having the phone ringing out loud, and then hearing someone talk through the phone.
I must say that the more I think and write about it, the more I am starting to think that I should let the idea go.
I just don't know any alternatives at this certain moment so I hope you still have some advice about making it work.
Thank you for your comment.
I am not sure if I will be able to answer your questions.
First of all, the setup is my own idea/initiative.
The person who could advice me about linux is currently unavailable.
I do have experience with Arduino and Processing. I hooked up the sensors via arduino, for example a proximity sensor.
If the sensor values pass the set threshold, Processing (processing.org) get's notified and plays a certain sound or video. As far as I'm concerned, processing has no abilities to automatically choose an audio output.
The communication between Arduino and Processing is serial.
When another sensor, for example a PIR movement sensor, senses movement and becomes HIGH, again processing will be notified, and the other audio output should be used to get the effect of having the phone ringing out loud, and then hearing someone talk through the phone.
I must say that the more I think and write about it, the more I am starting to think that I should let the idea go.
I just don't know any alternatives at this certain moment so I hope you still have some advice about making it work.
Thank you again!
The thing is, you are answering differently than my perception. Not a bad thing, I was just thinking slightly differently about things.
What are you calling "processing"? Is that a service, or just your term for the Linux CPU and the fact that a program is doing something, where this program is something that eventually you'll need to write?
One sensor is hooked up serial. Good, you can open a terminal and talk to it using a serial emulator and then see information come from it. You can use that within a program by attaching to that serial port and then processing this information.
The other sensor since you say High/Low, then seems to be on a GPIO? General Purpose Input/Output? Then you need to access the GPIO pins using a library call from Linux which will help you read or modify the pin values. Plus you may need to configure them to be explicitly either an input or an output. But, is my assumption there correct?
Just to advise, this is not some "one hour" project, it will likely take you a few hours to get some level of results where you learn things. Probably a few days or the better part of a week to get things much farther along. It's not unusual when you are very new to this. Therefore I'd try to learn things in the meantime, but for when you can meet up with your instructor,you can perhaps discuss with them the merits or drawbacks of your project choice.
It may be a fine project for you, just you also may have to put in a significant amount of time to achieve completion.
Or if it was supposed to be a very quick project, then perhaps it is a bit too far reaching.
The thing is, you are answering differently than my perception. Not a bad thing, I was just thinking slightly differently about things.
What are you calling "processing"? Is that a service, or just your term for the Linux CPU and the fact that a program is doing something, where this program is something that eventually you'll need to write?
One sensor is hooked up serial. Good, you can open a terminal and talk to it using a serial emulator and then see information come from it. You can use that within a program by attaching to that serial port and then processing this information.
The other sensor since you say High/Low, then seems to be on a GPIO? General Purpose Input/Output? Then you need to access the GPIO pins using a library call from Linux which will help you read or modify the pin values. Plus you may need to configure them to be explicitly either an input or an output. But, is my assumption there correct?
Just to advise, this is not some "one hour" project, it will likely take you a few hours to get some level of results where you learn things. Probably a few days or the better part of a week to get things much farther along. It's not unusual when you are very new to this. Therefore I'd try to learn things in the meantime, but for when you can meet up with your instructor,you can perhaps discuss with them the merits or drawbacks of your project choice.
It may be a fine project for you, just you also may have to put in a significant amount of time to achieve completion.
Or if it was supposed to be a very quick project, then perhaps it is a bit too far reaching.
It's a 5 month project so that's okay. Processing is software that can communicate with Arduino software.
I receive the values from my different sensors in Arduino, and send them to the processing software. I can read those, and I know how to connect an action to those values like playing a video. This is not the problem.
Are you saying that I should access the sensorpins by Linux instead of arduino to be able to be able to change the audio output?
It's a 5 month project so that's okay. Processing is software that can communicate with Arduino software.
I receive the values from my different sensors in Arduino, and send them to the processing software. I can read those, and I know how to connect an action to those values like playing a video. This is not the problem.
Are you saying that I should access the sensorpins by Linux instead of arduino to be able to be able to change the audio output?
Wouldn't it be easier to get the Arduino to do the sensing & then get it to illuminate a LED, if successful?
You could do the Linux thing after you've proved the sensor/Arduino side of things.
It's a 5 month project so that's okay. Processing is software that can communicate with Arduino software.
I receive the values from my different sensors in Arduino, and send them to the processing software. I can read those, and I know how to connect an action to those values like playing a video. This is not the problem.
Are you saying that I should access the sensorpins by Linux instead of arduino to be able to be able to change the audio output?
I'm better understanding now, which is that you have an Arduino development board where you are writing firmware that you then communicate to the Linux system with. Therefore your connection to Linux is serial UART? If so, then the suggestion here:
Quote:
Originally Posted by JeremyBoden
Wouldn't it be easier to get the Arduino to do the sensing & then get it to illuminate a LED, if successful?
You could do the Linux thing after you've proved the sensor/Arduino side of things.
I agree with JeremyBoden's advice here, which is to take care of the firmware on the Arduino first and then concentrate on the Linux side to play music files. Since you'd be writing Arduino firmware you can control what you send over the serial port, or accept. Sounds like a simple ASCII readable protocol, one or two characters of information back and forth. Once you define that, and the baud rate, you can then listen on the Linux system or even send data for controls to the Arduino, and all the Linux processing element does is have a receive state machine which says, "When you get 'A', play sound <blah-blah>", and so forth.
I'm a little confused. The OP's question seems to be completely unrelated to the Arduino, its sensors, its comms interface, etc. From what I can tell, he has already done all of that, it's working, it's irrelevant. All he's asking is how to play a music file on Linux through a specific audio interface, right? So why all of the questions about Arduino, serial ports, sensor types and interfaces, etc?
OP - At least some, if not most programs that can play music files on Linux allow you to specify the audio device to use. For example, mplayer has the -ao flag, you just need to know the name of the device to give it. On my laptop, when I want to play a video with the sound going to hdmi instead of the internal speakers, I run "mplayer -ao alsa:device=hw=0.7 <file>".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.