LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-05-2018, 12:37 AM   #1
eldiener
Member
 
Registered: Nov 2006
Distribution: Mepis, CentOS, OpenSuse
Posts: 81

Rep: Reputation: 16
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 ?
 
Old 03-05-2018, 02:40 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 10,858

Rep: Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232
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)
 
Old 03-05-2018, 07:07 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro
Posts: 6,319

Rep: Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226
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.
 
Old 03-05-2018, 09:14 AM   #4
eldiener
Member
 
Registered: Nov 2006
Distribution: Mepis, CentOS, OpenSuse
Posts: 81

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by BW-userx View Post
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.
 
Old 03-05-2018, 09:16 AM   #5
eldiener
Member
 
Registered: Nov 2006
Distribution: Mepis, CentOS, OpenSuse
Posts: 81

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by pan64 View Post
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.
 
Old 03-05-2018, 09:32 AM   #6
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro
Posts: 6,319

Rep: Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226Reputation: 1226
Quote:
Originally Posted by eldiener View Post
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.
 
Old 03-05-2018, 02:49 PM   #7
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,154

Rep: Reputation: 698Reputation: 698Reputation: 698Reputation: 698Reputation: 698Reputation: 698
Maybe look at examples from alsa-project

http://www.alsa-project.org/alsa-doc.../examples.html
(/test/pcm.c & /test/pcm_min.c)
 
Old 03-05-2018, 04:21 PM   #8
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: Slackware
Posts: 8,148

Rep: Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273Reputation: 3273
Quote:
Originally Posted by eldiener View Post
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?
 
Old 03-05-2018, 06:38 PM   #9
Mill J
Member
 
Registered: Feb 2017
Location: 127.0.0.1 Sweet 127.0.0.1
Distribution: Void, LFS,Tahrpup, Quirky on Rpi and many others
Posts: 793
Blog Entries: 1

Rep: Reputation: 289Reputation: 289Reputation: 289
@OP what proggraming language are you using?
 
Old 03-06-2018, 12:39 AM   #10
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 10,858

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


Reply

Tags
api, wav


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
unable to play wave file navin_karnam Linux - Software 2 07-05-2007 10:54 PM
linux wave file ehsong Programming 2 01-20-2006 11:44 AM
Can't play wave files (XMMS, Kaffeine, etc.) apachedude Linux - Software 5 12-30-2004 02:17 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration