LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Programatically play a wave file in Linux (https://www.linuxquestions.org/questions/programming-9/programatically-play-a-wave-file-in-linux-4175624958/)

eldiener 03-05-2018 12:37 AM

Programatically play a wave file in Linux
 
Does Linux have a programming API to play a particularly named .wav file ? I know I can call one of the exec functions to run 'aplay somewave.wav', but is there a fairly common library and API which can easily do this also so I do not have to start another process ?

pan64 03-05-2018 02:40 AM

in that case you need to start a "music server" or something like that, which will play the wav file for you. But that means you need a process running and listening continuously. mpd is one of them.
(so you will need to start a process anyway)

BW-userx 03-05-2018 07:07 AM

on the matter of 'process'. Whenever someone does something, anything it goes through a process in order to accomplish the task.

Process: a series of actions or steps taken in order to achieve a particular end.

In the case of Linux/GNU the process gets an ID to keep track of each process that is taking place within itself. Hence the PID.

It's inevitable.

eldiener 03-05-2018 09:14 AM

Quote:

Originally Posted by BW-userx (Post 5827458)
on the matter of 'process'. Whenever someone does something, anything it goes through a process in order to accomplish the task.

Process: a series of actions or steps taken in order to achieve a particular end.

In the case of Linux/GNU the process gets an ID to keep track of each process that is taking place within itself. Hence the PID.

It's inevitable.

I was using the term "process" in the specific sense of invoking a program to play the .wav file.

eldiener 03-05-2018 09:16 AM

Quote:

Originally Posted by pan64 (Post 5827400)
in that case you need to start a "music server" or something like that, which will play the wav file for you. But that means you need a process running and listening continuously. mpd is one of them.
(so you will need to start a process anyway)

It sounds like what you are saying is that there exists no operating system call that will play a .wav file, or any sound file for that matter. If that is indeed the case then I must invoke another program to do it.

BW-userx 03-05-2018 09:32 AM

Quote:

Originally Posted by eldiener (Post 5827498)
I was using the term "process" in the specific sense of invoking a program to play the .wav file.

it still falls under process. to invoke something to run something else, or itself, still falls under 'a process'. No matter how one slices or dices it, it requires a process. the invoking a program it gets a PID. write something using common library and API still gets a PID.

keefaz 03-05-2018 02:49 PM

Maybe look at examples from alsa-project

http://www.alsa-project.org/alsa-doc.../examples.html
(/test/pcm.c & /test/pcm_min.c)

dugan 03-05-2018 04:21 PM

Quote:

Originally Posted by eldiener (Post 5827379)
Does Linux have a programming API to play a particularly named .wav file ? I know I can call one of the exec functions to run 'aplay somewave.wav', but is there a fairly common library and API which can easily do this also so I do not have to start another process ?

gstreamer?

Mill J 03-05-2018 06:38 PM

@OP what proggraming language are you using?

pan64 03-06-2018 12:39 AM

I think you missed a very important point: there is always an app/process behind every API.


All times are GMT -5. The time now is 09:45 AM.