LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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, 01:37 AM   #1
eldiener
Member
 
Registered: Nov 2006
Distribution: Mepis, CentOS, OpenSuse
Posts: 103

Rep: Reputation: 17
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, 03:40 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,613

Rep: Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497
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, 08:07 AM   #3
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro / Parrot
Posts: 7,390

Rep: Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491
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, 10:14 AM   #4
eldiener
Member
 
Registered: Nov 2006
Distribution: Mepis, CentOS, OpenSuse
Posts: 103

Original Poster
Rep: Reputation: 17
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, 10:16 AM   #5
eldiener
Member
 
Registered: Nov 2006
Distribution: Mepis, CentOS, OpenSuse
Posts: 103

Original Poster
Rep: Reputation: 17
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, 10:32 AM   #6
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Slackware 14.2 / Slackware 14.2 current / Manjaro / Parrot
Posts: 7,390

Rep: Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491Reputation: 1491
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, 03:49 PM   #7
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,230

Rep: Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714Reputation: 714
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, 05:21 PM   #8
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: Slackware
Posts: 8,553

Rep: Reputation: 3571Reputation: 3571Reputation: 3571Reputation: 3571Reputation: 3571Reputation: 3571Reputation: 3571Reputation: 3571Reputation: 3571Reputation: 3571Reputation: 3571
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, 07:38 PM   #9
Mill J
Member
 
Registered: Feb 2017
Location: 127.0.0.1 Sweet 127.0.0.1
Distribution: Void, LFS, Haiku, Quirky on Rpi and many others
Posts: 886
Blog Entries: 2

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

Rep: Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497Reputation: 3497
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 11:54 PM
linux wave file ehsong Programming 2 01-20-2006 12:44 PM
Can't play wave files (XMMS, Kaffeine, etc.) apachedude Linux - Software 5 12-30-2004 03:17 AM

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

All times are GMT -5. The time now is 01:07 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