9 Replies - 1043 Views - Last Post: 12 May 2014 - 01:57 PM Rate Topic: -----

#1 gabeRocks   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-May 14

I am trying to make a function thatll play music in a game. OS: linux

Posted 09 May 2014 - 05:46 PM

Hey guys I am sure some one has asked this before, but I am trying to make a c function that can play a in a game. I have no idea how to go about this. I have looked around the web and most of what came up required the implemintation of a function called playsound which uses windows.h I am currently using linux and its normal terminal

any help would be much appreciated thank you
Is This A Good Question/Topic? 0
  • +

Replies To: I am trying to make a function thatll play music in a game. OS: linux

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12646
  • View blog
  • Posts: 45,819
  • Joined: 27-December 08

Re: I am trying to make a function thatll play music in a game. OS: linux

Posted 09 May 2014 - 05:55 PM

Is this a game you are developing or an existing game? More details would be helpful, including the name of the game if it isn't one you developed.
Was This Post Helpful? 0
  • +
  • -

#3 gabeRocks   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-May 14

Re: I am trying to make a function thatll play music in a game. OS: linux

Posted 09 May 2014 - 05:57 PM

It is a game some friends and i are developing
any info would be much abliged, including resources
Was This Post Helpful? 0
  • +
  • -

#4 tarmizi_adam2005   User is offline

  • جوروترا

Reputation: 287
  • View blog
  • Posts: 986
  • Joined: 18-April 09

Re: I am trying to make a function thatll play music in a game. OS: linux

Posted 09 May 2014 - 06:40 PM

Hi,

Well I don't use Linux, but doing a simple google search, I found that you could either use a Library to do so. Or something called /dev/dsp programming. I think if you want to do complex sound processing you should use a library for example a simple search I found ALSA. For the /dev/dsp programming you can look here. Looks kinda complicated to me. Not sure if this helps in any way.
Was This Post Helpful? 0
  • +
  • -

#5 jimblumberg   User is offline

  • member icon

Reputation: 5761
  • View blog
  • Posts: 17,640
  • Joined: 25-December 09

Re: I am trying to make a function thatll play music in a game. OS: linux

Posted 09 May 2014 - 07:18 PM

You may want to look at either the ALSA system or the OSS system.

Jim
Was This Post Helpful? 0
  • +
  • -

#6 snoopy11   User is offline

  • Engineering ● Software
  • member icon

Reputation: 1556
  • View blog
  • Posts: 4,930
  • Joined: 20-March 10

Re: I am trying to make a function thatll play music in a game. OS: linux

Posted 10 May 2014 - 07:45 AM

Well,

You are going to have use a library of some sort as mentioned above.

irrKlang is cross platform and the quality of playback is highly professional, the best sound library I have ever come across I would use that.

irrKlang Download link.

Regards

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#7 vividexstance   User is offline

  • Tiocfaidh ár lá
  • member icon

Reputation: 794
  • View blog
  • Posts: 2,880
  • Joined: 31-December 10

Re: I am trying to make a function thatll play music in a game. OS: linux

Posted 10 May 2014 - 09:43 AM

I like the SFML library which is gaining popularity. It stands for Simple Fast Multimedia Library and it includes a simple to use audio library. I haven't used that part of the library, but their site has lots of documentation and tutorials. Here's a link to their tutorial on the audio part of the library.
Was This Post Helpful? 0
  • +
  • -

#8 gabeRocks   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 09-May 14

Re: I am trying to make a function thatll play music in a game. OS: linux

Posted 12 May 2014 - 11:41 AM

is there a way to play music without external connections or downloads. say a library i can simply #include<>
Was This Post Helpful? 0
  • +
  • -

#9 jimblumberg   User is offline

  • member icon

Reputation: 5761
  • View blog
  • Posts: 17,640
  • Joined: 25-December 09

Re: I am trying to make a function thatll play music in a game. OS: linux

Posted 12 May 2014 - 12:28 PM

Quote

is there a way to play music without external connections or downloads. say a library i can simply #include<>

If you mean rather than writing something yourself, no. There are no standard functions that will play a sound, let alone play music.

Jim
Was This Post Helpful? 0
  • +
  • -

#10 snoopy11   User is offline

  • Engineering ● Software
  • member icon

Reputation: 1556
  • View blog
  • Posts: 4,930
  • Joined: 20-March 10

Re: I am trying to make a function thatll play music in a game. OS: linux

Posted 12 May 2014 - 01:57 PM

While I agree with jim of course,

It is possible to do it without a library but you are going to have to do it with some inline assembly,

this amounts to basically writing your own library function for playing sound files under linux,

so maybe, well definitely more trouble than its worth.

But just for your information a link to a page that discusses how to play a .raw 44.1 khz 16 bit signed file under linux in assembly.

http://asm.sourcefor...cles/audio.html

Regards

Snoopy.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1