ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
In short, what I want to achieve is this:
echo "a b c a" | piano.sh
And hear it, like it was played on a piano.
As you can see, I really would like to keep it simple, it is for a school project, and this is a minor but important thing. I am getting the data from the serial port and that part is working.
I have been looking at software synthesizers etc. but again, I want it to be simple. :-)
Has anyone done anything similar or related to this? Is it at all possible?
The sound card drivers direct a sound card on what sounds/notes to play. So, you need to program something that will send the right instruction for each note to the sound card driver. You will need more than a script. The only sound that script languages like bash have been programmed to play is the monotone "beep". I am not sure whether an Amarok script will do what you need. A "how to" is at http://amarok.kde.org/wiki/Script-Wr...o#Introduction
In short, what I want to achieve is this:
echo "a b c a" | piano.sh
It depends how much programming you want to do (and which language).
One way would be to generate midi notes; for example, in Python you could use a module such as pyfluidsynth, or even generate midi events directly from the incoming note list.
A quick and ugly way would be to create a whole lot of mp3 files with the different notes, and then use a shell script to run mpg321 on the ones that match the notes coming in!
It depends how much programming you want to do (and which language).
One way would be to generate midi notes; for example, in Python you could use a module such as pyfluidsynth, or even generate midi events directly from the incoming note list.
A quick and ugly way would be to create a whole lot of mp3 files with the different notes, and then use a shell script to run mpg321 on the ones that match the notes coming in!
An interesting idea, for a console.
The use of MIDI is a traditional way, but I think if you can manage to somehow "mix" the sound of the mp3 notes (using PulseAudio or something like that), it will be much more real. The sound of MIDI notes is rather flat, you know.
I'm no expert on programming and sound stuff, but an enthusiast of music and the console . Please keep posting the result of your work here.
neonsignal,
Thanks for that. I do not know how after many years I missed SoX, that I now find is a standard offering of many Linux / Unix distributions.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.