Good day to all.

I would like to ask some help regarding C++ sounds. I read some codes in playing sounds using C++ and this codes was based on WINDOWS. I would like to as if there is a possibility that I can play a wav file in LINUX using C++. I am a begginer in C++ and I really need your help guys.


Thank you.

Hunterfish.

Recommended Answers

All 6 Replies

#include <windows.h>
PlaySound("file.wav", NULL, SND_ASYNC | SND_FILENAME);

You didn't mention what compiler.

commented: Are you an idiot? windows.h on linux? -4

He said he has examples for Windows but what he wants is examples that work under Linux

Sorry there is SDL which can do what you want. You can use this link to read about the API.

You can also create a shell script to play a wav file:

#!/bin/bash
mplayer (replace with your favorite media player) $1
chmod +x wavplayer
./wavplayer file.wav

Thank you. I really appreciate it but It doesn't work.Any other codes/scripts using C++.

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.