Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

Sign in to follow this  
ClareXoBearrx3R9

(C++) Playing External Sound

Recommended Posts

ClareXoBearrx3R9

Does anyone happen to know how to play external sounds in C++, assuming I have a .wav or .mp3 file? I'm looking to just play a short 3 second sound from a file that I have but can't seem to find any way to do it with C++.

For instance, per the website at http://gtaxscripting.blogspot.com/2013/03/tut-playing-native-sounds-and-external.html, one could use:

Private exSound As System.Media.SoundPlayerexSound = New System.Media.SoundPlayerexSound.SoundLocation = ".\path\to\sound.wav"exSound.Load()

and simply call a method that implements the above snippet to play the sound. However, that is either .NET or C# and the project I'm working on is in C++.

I've tried looking for something similar for C++ and found this: https://msdn.microsoft.com/en-us/library/system.media.soundplayer(v=vs.110).aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-2but have no idea what files need to be included, etc.

Thanks in advance :)

Edited by ClareXoBearrx3

Share this post


Link to post
Share on other sites
leftas

Skorpo mentioned here. How to play music with Windows Sound Player

@ http://gtaforums.com/topic/745662-get-players-audio-volume-setting/

 

 

Anyone know how I can get/set the current music volume setting through code? I'm finishing up the new Ambiance script and I'm sure players would like the volume to be controllable in a native-feeling way.

 

Hi,

for MP3 you can try s.t. like this (C++):


#include <windows.h>#include <MMSystem.h>#pragma comment(lib, "winmm.lib"). . . .mciSendString(TEXT("open Test.mp3"),NULL,0,0);mciSendString(TEXT("play Test.mp3 repeat"),NULL,0,0);mciSendString(TEXT("setaudio Test.mp3 output volume to 500"),NULL,0,0); // Volume = 500 (0 - 1000)

or in SCO (I never checked this! Maybe the value is NOT the volume!?!)

SET_VARIABLE_ON_SOUND(uint sound, char *varname, float value);

 

Best wishes,

Paul.

Edited by leftas

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

Beautiful - didn't see that. Thanks!

Share this post


Link to post
Share on other sites
GRAX

Beautiful - didn't see that. Thanks!

LOL why you 'like' leftas for his hint but NOT skorpro for his "beautiful" code???

just wondering ;)

Share this post


Link to post
Share on other sites
Jitnaught

 

Beautiful - didn't see that. Thanks!

LOL why you 'like' leftas for his hint but NOT skorpro for his "beautiful" code???

just wondering ;)

 

She never named anyone.

Share this post


Link to post
Share on other sites
leftas

 

Beautiful - didn't see that. Thanks!

LOL why you 'like' leftas for his hint but NOT skorpro for his "beautiful" code???

just wondering ;)

 

What does 'like' changes ? I think you sitting too much in Facebook, dude. And I'm not sure why 'c++ noob' complaining about likes. Like LetsPlayerOrDy mentioned, she never named anyone, she just said that this code beautiful, and thanked me for linking to that comment.

And I want to say that everyone who's programming - first help should be Google, not forums. I just did a search on google, and I found numerous way how to play sound and who reads in msdn a lot, also knows that :)

And GRAX,

If I wouldn't linked Skorpo comment, just Skorpo after some time(I don't know when you be on forums) would post the same. And okay, if don't like that I linking the comments, I will post a code by myself.

 

P.S. I'm not about that like, but how YOU, GRAX, complaining about the things, which aren't including YOU.

 

Best wishes,

Paul.

Share this post


Link to post
Share on other sites
GRAX

@letsplayordy

i never said "she" named anyone!

just wondering why "she" liked someone for a HINT but not the programmer for his SOURCE CODE (check out the link).

 

@leftas

im sitting too much in FB? are you a joker? but its ok when YOU liked letsplayordys comment?? LOL really funny ;)

yes im a c++ noob. im sure you were born as a c++ PRO right?

dont be sulk! i never said that linking is a bad thing!

 

btw just because of a pic of a 14yr old girl doesnt mean the user is a GIRLS ;)

Share this post


Link to post
Share on other sites
Jitnaught

You said that he/she liked leftas for his post but not Skorpro for his code. He/She was just saying thank you to leftas for linking the code. When did he/she ever say that he/she didn't appreciate Skorpro for his code?

Oh and the reason I said "she" is because I did not look into his/her profile and see the gender was male and the age was 20+. So the only thing I had to go off of was his/her picture.

Edited by LetsPlayOrDy

Share this post


Link to post
Share on other sites
leftas

@letsplayordy

i never said "she" named anyone!

just wondering why "she" liked someone for a HINT but not the programmer for his SOURCE CODE (check out the link).

 

@leftas

im sitting too much in FB? are you a joker? but its ok when YOU liked letsplayordys comment?? LOL really funny ;)

yes im a c++ noob. im sure you were born as a c++ PRO right?

dont be sulk! i never said that linking is a bad thing!

 

btw just because of a pic of a 14yr old girl doesnt mean the user is a GIRLS ;)

Yes. Because it seems that "like" button here, works the same like in facebook for you, this is not social network. Nope, sorry, I'm not joker :) I never said like button is a bad thing, but You complaining about, whatever she or he liking the comments. When I see a good post, I click on like button.

Sorry I was angry at that time, but if you will read in msdn or look for tutorials in network then You will improve your skills. But please, then don't complain about things which aren't including You.

 

Best regards,

Paul.

Edited by leftas

Share this post


Link to post
Share on other sites
Skorpro

Hi LetsPlayOrDy, leftas, ClareXoBearrx3, GRAX and everyone,

please relax, this forum is pure fun and/or hobby for all of us! :D

 

...but You complaining about, whatever she or he liking the comments. ...

just wondering ;)

I think he didn't mean it. Due to " ;)" :)

 

If I wouldn't linked Skorpo comment, just Skorpo after some time(I don't know when you be on forums) would post the same.

Good idea -> Added to How to use Aru's C++ ScriptHook SDK ;) Joke aside, I have forgotten this code, thanx for the link :)

 

btw just because of a pic of a 14yr old girl doesnt mean the user is a GIRLS ;)

So the only thing I had to go off of was his/her picture.

Haha, I also thought he is a 'girl' :D

 

 

My comment:

If someone 'like' my work it's nice and if not it's truly uninteresting for me! I don't make this for "fame", it's just for fun and to help other modders/coders :)
...And yes, sometimes I write a note like "please make a small credit..." under my sources, I do this because of fairness and because I was a member of some scene groups in the good old AMIGA days (during the 90's. Yes, I'm a 'old geezer' ;)) and we all wrote credits ('greetings' & 'thanx') in our intros/demos...
> once learned - never forget < ... you know what I mean :D

 

Anyway, there is no reason anymore to talk about it -> Peace and let's have fun :)

 

Skorpro

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

Haha, didn't see all of this until now. :p

 

Anyhow, I thank everyone for their help :D

 

As for the name, real name is Christopher ... but the whole female thing is a long story. :p

Share this post


Link to post
Share on other sites
Jitnaught

As for the name, real name is Christopher ... but the whole female thing is a long story. :p

Well then sorry about calling you a girl lol :)

Share this post


Link to post
Share on other sites
InfamousSabre

Haha, didn't see all of this until now. :p

 

Anyhow, I thank everyone for their help :D

 

As for the name, real name is Christopher ... but the whole female thing is a long story. :p

Nothing wrong with transitioning, if that's what the long story is about :p

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

Hahaha, nope - didn't transition :p

Mainly just some humorous stuff :)

 

And @Dirty: No prob lol :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.