LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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: 106

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, 02:40 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,041

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
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: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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: 106

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, 09:16 AM   #5
eldiener
Member
 
Registered: Nov 2006
Distribution: Mepis, CentOS, OpenSuse
Posts: 106

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, 09:32 AM   #6
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
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,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
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: distro hopper
Posts: 11,249

Rep: Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323Reputation: 5323
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
Senior Member
 
Registered: Feb 2017
Location: @127.0.0.1
Distribution: Mint, Void, MX, Haiku, PMOS, Plasma Mobile, and many others
Posts: 1,258
Blog Entries: 2

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

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


Reply

Tags
api, wav



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 06:02 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
Open Source Consulting | Domain Registration