Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1065274 Posts in 43452 Topics- by 35483 Members - Latest Member: punchdrunklucia

November 21, 2014, 08:20:36 AM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook).ogg playback in C#
Pages: [1]
Print
Author Topic: .ogg playback in C#  (Read 4680 times)
TheGrandHero
Level 0
**



View Profile WWW Email
« on: September 04, 2012, 05:04:11 AM »

I'm currently using the OpenTK library to access OpenGL and OpenAL in C#. Since I'm not using .NET/XNA (in order to port to Linux and Mac later), I'm having a bit of a setback when it comes to audio. I have .wav playback up and running, but that's raw PCM data that took maybe ten minutes to code a loader for, and to use that for my game's soundtrack would result in a huge waste of disk space.

Is there any stable C# library for .ogg playback, or at least decoding? The best I've come across thus far is DragonOgg, but after a week or so of tinkering I haven't had much use with it. Playback adds a lot of noise in the background that isn't there when playing the .ogg files elsewhere, seeking within the file (to loop back to the beginning a song, for example) seems buggy, it's not well documented, and on top of all that it hasn't been touched by the developers in almost two years.

Failing a full playback library, is there at least any basic binding of libvorbis to C#? My gut instinct (and Google) are both saying "no". Alternate formats/solutions are welcome.
Logged

zalzane
Level 5
*****


View Profile
« Reply #1 on: September 04, 2012, 06:05:37 AM »

couldnt you just use monogame to play it?
Logged
TheGrandHero
Level 0
**



View Profile WWW Email
« Reply #2 on: September 04, 2012, 07:10:27 AM »

I'm using OpenTK directly without going through MonoGame. And as far as I'm aware, MonoGame does not have a specific go-to audio solution. Some games ported from XNA appear to just make do with .wav files for their soundtrack.
Logged

Zaknafein
Level 4
****


renaud.bedard@gmail.com
View Profile WWW Email
« Reply #3 on: September 04, 2012, 08:42:26 AM »

I'm in the same situation, but I've been told to look into NAudio. I'm doing that right now, so I'll let you know how that went.

http://naudio.codeplex.com/releases/view/79035
Logged

TheGrandHero
Level 0
**



View Profile WWW Email
« Reply #4 on: September 04, 2012, 09:51:06 AM »

Looks promising, but as far as I can see it only works under .NET, so I'm not sure how much use it would be for my project.
Logged

Zaknafein
Level 4
****


renaud.bedard@gmail.com
View Profile WWW Email
« Reply #5 on: September 04, 2012, 10:17:01 AM »

Ah, this could be a dealbraker for me too. Should've looked more carefully. :/
Logged

Maud'Dib Atreides
Level 4
****


Obsessed with space


View Profile WWW Email
« Reply #6 on: September 04, 2012, 10:23:53 AM »

I'm using OpenTK for OpenGL and fmodex is working wonderfully for sound playback with .ogg vorbis andI believe it also runs on linux (its multiplatform, right) but this depends on if you're choosing to make a hobby or commercial game
« Last Edit: September 04, 2012, 10:31:34 AM by #Sharp » Logged

Guy: Give me all of your money.
Chap: You can't talk to me that way, I'M BRITISH!
Guy: Well, You can't talk to me that way, I'm brutish.
Chap: Somebody help me, I'm about to lose 300 pounds!
Guy: Why's that a bad thing?
Chap: I'M BRITISH.
TheGrandHero
Level 0
**



View Profile WWW Email
« Reply #7 on: September 04, 2012, 10:59:03 AM »

Ah, this could be a dealbraker for me too. Should've looked more carefully. :/
Looking at the NVorbis sister project, though, it looks like it outputs raw buffer data. Recompiling the library under Mono and then feeding this to OpenAL instead of NAudio might be possible.

One of the suggested features of NVorbis is Mono support, and the project is still under actual development (unlike DragonOGG) so this might actually be what I'm looking for. Maybe.

I'm using OpenTK for OpenGL and fmodex is working wonderfully for sound playback with .ogg vorbis andI believe it also runs on linux (its multiplatform, right) but this depends on if you're choosing to make a hobby or commercial game
It's a commercial game, but I don't see it making enough to justify a $500 license. I've already spent more than I was planning to get this project polished and done, so FMOD Ex isn't an option I feel is on the table. Not for this game, at least.
Logged

Zaknafein
Level 4
****


renaud.bedard@gmail.com
View Profile WWW Email
« Reply #8 on: September 04, 2012, 03:50:49 PM »

Just so you know, I implemented streaming from an .ogg file using OpenAL/OpenTK and NVorbis, works great! Only tested on Windows, but I don't see why it wouldn't work elsewhere.
Logged

TheGrandHero
Level 0
**



View Profile WWW Email
« Reply #9 on: September 05, 2012, 04:03:17 AM »

Okay, thanks for the heads up! I'll probably fiddle with it sometime today. Might even try and get it running under Linux just to see if it works. If nothing else, the fact that it's actually still being worked on is a good sign.
Logged

Zaknafein
Level 4
****


renaud.bedard@gmail.com
View Profile WWW Email
« Reply #10 on: September 05, 2012, 08:57:34 AM »

I wrote about and released the code I used to do that : http://theinstructionlimit.com/ogg-streaming-using-opentk-and-nvorbis
Logged

Maud'Dib Atreides
Level 4
****


Obsessed with space


View Profile WWW Email
« Reply #11 on: September 05, 2012, 10:28:38 AM »

(adding this thread to my bookmarks)
Logged

Guy: Give me all of your money.
Chap: You can't talk to me that way, I'M BRITISH!
Guy: Well, You can't talk to me that way, I'm brutish.
Chap: Somebody help me, I'm about to lose 300 pounds!
Guy: Why's that a bad thing?
Chap: I'M BRITISH.
TheGrandHero
Level 0
**



View Profile WWW Email
« Reply #12 on: September 05, 2012, 01:21:12 PM »

I noticed your fork of NVorbis this morning, Zaknafein. I'd gotten streaming to the buffers down just fine, but the output was partially garbled. Seeing how you converted the decoded PCM data from a float array to a short array was just what I needed to get it to actually come out right. Testing with the same .ogg files I tried under DragonOGG was successful; the faint trailing white noise from DragonOGG was eliminated and the audio was nice and crisp.

Thanks for pointing me to NAudio, by the way. Like I mentioned in my opening post, countless Google searches turned up nothing and I never would have stumbled onto NVorbis without glancing at the NAudio project page.
Logged

rivon
Level 10
*****



View Profile
« Reply #13 on: September 11, 2012, 07:28:05 AM »

irrKlang can be used from C#.
Logged
TheGrandHero
Level 0
**



View Profile WWW Email
« Reply #14 on: September 13, 2012, 04:59:22 AM »

Not quite what I, personally, am looking for, but for others who need decent access to audio irrKlang looks like a pretty good deal for a commercial library.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic