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.

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.

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 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.

>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.

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.

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.

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

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.

>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.

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).

>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? ;)

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.