0

I can so far find Nothing whatsoever that will allow me to easily play a wav sound in a console app in linux. It's like I have to create my own audio player to play a half second clip of a cat meowing. Does anyone have any experience? I'd really appreciate it.

4
Contributors
14
Replies
15
Views
12 Years
Discussion Span
Last Post by Rearden
Featured Replies
  • 1

    I don't have a Linux Box, but if there is a program that plays wave files you could call it with system(). Something like [code] system("WavePlayer cat.wav") [/code] Read More

0

I already utilized the forum search feature to find that article, that's why i posted a new topic. That topic deals with windows programming. I am talking about linux programming.

1

I don't have a Linux Box, but if there is a program that plays wave files you could call it with system(). Something like

system("WavePlayer cat.wav")
0

I don't have a Linux Box, but if there is a program that plays wave files you could call it with system(). Something like

system("WavePlayer cat.wav")

I dont think you can use the "System" command in linux. I'm pretty sure its a windows only command.

But what i think i would do is just piggy back off of another program (linux does this all the time) and is what i think vegaseat is refering to. I'd install a program like mpg123 (basic mp3 player) and "exec" the program with the "-q" (quiet) option. I know its not a wav file but mp3's are just better anyway.

0

>I dont think you can use the "System" command in linux.
I don't know about the "System" command, but the system function is standard C, declared in stdlib.h.

1

That is exactly what I ended up doing. The system call does work in linux. I don't see why it wouldn't as I think it is standard ANSI. However, on my system at least, the system function is in iostream. Maybe it is in both? Anyway the program is call esdplay. so a call to it would look like system("esdplay cat.wav");

While this works and I eventually resorted to it. I think it's cheating. For now, I'm going to leave it as is but in the future, I will use OpenAL which if you didn't figure it out from the name is the audio equivalent to openGL. Thanks for your suggestions everyone.

0

I stand corrected on the "system" function in C. Yeah i just looked it up to make sure. I just realized why i thought that. Not a C or C++ programmer anymore so its been a while since i've written much in it.

As far as feeling like its cheating, I understand why you would feel that way but keep in mind, at least from a linux stand point, using other programs to accomplish a small part of your program is a good idea. It helps keep programs smaller and creation of programs faster. Plus its nice not having to recreate the wheel everytime you need one.

0

>I think it's cheating.
For theorists, cheating is an option. For the rest of us, it's a necessity. :)

0

I understand how it is probably better to just use the system command instead of doing it all myself. I'm not sure why it bothers me so much but it really does. It seems like a failure. The system call also makes it unportable by default.

0

>The system call also makes it unportable by default.
That's irrelevant. You're trying to do something inherently non-portable, so you'll be using a non-portable solution no matter how you look at it. The trick is to separate the non-portable parts from the portable parts so as to make porting the program easier.

0

Also, another comment on the whole cheatting thing. Ever heard of windows API calls? its another example (obvious not valid here) of program "cheating" being used to its fullest. Of course using other linux programs to do tasks for you is probably as close to using a windows api as i think is possible in linux.

I agree with Narue on the ports comment but you could also ask java's jvm what the os type is (i presume) and do both system calls in an if statement. I only recommend something like that when its just a small amount of code otherwise you could make your program fatter then it needs to be (just like adding code that reinvents the wheel).

0

>you could also ask java's jvm what the os type is
Assuming the JVM is installed. Since this isn't the Java forum, we can't assume that it is.

>and do both system calls in an if statement
Okay, that covers two operating systems. Since there's a concern about portability, how do you propose dealing with the other dozen and a half systems? ;)

0

Sorry about the java post, thats my more active forum but i got bored and was posting over here too.

Well the concept will work, there are otherways to finger print the os.

0

Those are good points. I think that for now, i'm going to leave the system call and just change it to the windows API if i ever port it to windows. This isn't a huge application so it's not a problem to go back and change the code. I just don't want to get into bad habits for when it is a big application. Thank you for all of your help so far guys.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.