View previous topic :: View next topic |
Author |
Message |
paulj Guru
Joined: 30 Sep 2004 Posts: 511 Location: Wales, UK
|
Posted: Fri Feb 23, 2018 1:10 pm Post subject: Programming Sound under Linux |
|
|
I want to generate sounds with a program (as opposed to playing a sound file), but there is a surprising lack of up to date information about how to go about this process. Are any of you aware of decent, recent documentation or tutorials to enable programming of polyphonic sound, ideally in C/C++, but I'll take anything at the moment!
Many thanks! |
|
Back to top |
|
|
audiodef Watchman
Joined: 06 Jul 2005 Posts: 6639 Location: The soundosphere
|
|
Back to top |
|
|
paulj Guru
Joined: 30 Sep 2004 Posts: 511 Location: Wales, UK
|
Posted: Sun Feb 25, 2018 2:32 pm Post subject: |
|
|
Thanks audiodef. I am aware of the gentoo studio, and have been promising to load it up on one of my machines for some time (I play saxophone, clarinet and guitar and wanted to explore it further).
Coming originally from a Commodore Amiga background, I was surprised to find that programming sound seems to be such a niche activity. I want to use C/C++ because the sound is simply an output, and not the be-all and end-all of the application - I want to experiment with shepard tones, as a precursor to experimenting with a new type of vario for model gliders. I don't want to learn another language in order to achieve this aim. There is a book I came across called "Linux Sound Programming" (https://www.apress.com/gb/book/9781484224953), but the preview pages seem to show that this spends lots of pages regurgitating things like pulseaudio configuration files and not on the core concepts. I am not encouraged to pay good money for it... |
|
Back to top |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10587 Location: Somewhere over Atlanta, Georgia
|
Posted: Sun Feb 25, 2018 4:12 pm Post subject: |
|
|
Some simple audio file formats (e.g., .wav) seem to be trivially easy to find on the Internet. For instance, here, here, and here. Is this not what you're looking for? And why create anything other than a simple format, so long as it's versatile enough to support multiple bit rates and channels? There are a myriad of encoders available to convert to whatever final format you want. Those structures are likewise easy to create in C/C++.
Similarly, for programmatic audio output, there seem to be some tutorials on the ALSA Project site.
- John _________________ I can confirm that I have received between 0 and 499 National Security Letters. |
|
Back to top |
|
|
audiodef Watchman
Joined: 06 Jul 2005 Posts: 6639 Location: The soundosphere
|
|
Back to top |
|
|
Ant P. Watchman
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Sun Feb 25, 2018 6:10 pm Post subject: |
|
|
SDL seems to be able to cope with sound being generated and pushed to it in realtime, if that's what you meant to do. There's also OpenAL but I've heard it's downright painful to program for. |
|
Back to top |
|
|
paulj Guru
Joined: 30 Sep 2004 Posts: 511 Location: Wales, UK
|
Posted: Sun Feb 25, 2018 6:32 pm Post subject: |
|
|
John R. Graham wrote: | Some simple audio file formats (e.g., .wav) seem to be trivially easy to find on the Internet. For instance, here, here, and here. Is this not what you're looking for? And why create anything other than a simple format, so long as it's versatile enough to support multiple bit rates and channels? There are a myriad of encoders available to convert to whatever final format you want. Those structures are likewise easy to create in C/C++.
Similarly, for programmatic audio output, there seem to be some tutorials on the ALSA Project site.
- John |
What I want to do is this:
Code: | Generate a polyphonic tone, with three notes each one octave apart.
while true [
Read the pressure from the barometric sensor
calculate the new height
calculate the pitch of the new tone
generate the three notes based on this, adjusting the relative volumes to enhance the Shepard Tone effect
] |
Ultimately this should occur in a microcontroller, or using something like a raspberry pi, but for the first stage, I wanted to create a test program on my desktop, with dummy input. I guess I could generate a selection of wav files and play those, but I should be able to generate the notes programmatically. The stuff on the ALSA site seems to be dreadfully out of date, and actually suggests you use the information provided for Jack. However, this also seems to be sparse in terms of information. I'll keep looking!
Last edited by paulj on Sun Feb 25, 2018 6:34 pm; edited 1 time in total |
|
Back to top |
|
|
paulj Guru
Joined: 30 Sep 2004 Posts: 511 Location: Wales, UK
|
Posted: Sun Feb 25, 2018 6:33 pm Post subject: |
|
|
Ant P. wrote: | SDL seems to be able to cope with sound being generated and pushed to it in realtime, if that's what you meant to do. There's also OpenAL but I've heard it's downright painful to program for. |
Thanks Ant P. - I'll look into this. |
|
Back to top |
|
|
Irre Guru
Joined: 09 Nov 2013 Posts: 434 Location: Stockholm
|
Posted: Sun Feb 25, 2018 7:31 pm Post subject: |
|
|
Try to implement your music generating programs on a graphic card with billions of transistors! |
|
Back to top |
|
|
geki Advocate
Joined: 13 May 2004 Posts: 2387 Location: Germania
|
|
Back to top |
|
|
|