• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Kercyn

SDL_mixer and sound sample format

4 posts in this topic

Hello everybody.

I'm currently developing the sound engine for my game engine using SDL_mixer 2 and there is something I don't understand. There is a function called Mix_OpenAudio which initializes the mixer and accepts a few arguments. One of those arguments is called format, and it can take these values. My sound knowledge is almost none, so bear with me.

As far as I understand this, format tells SDL how to parse the sounds it's given to play. I tried playing an SFX which was in 32-bit float format while passing different format values to Mix_OpenAudio and the sound played the same every time. Although I might have thought it played the same, as it was a quick *whoosh* SFX. If I have an RGB image and I parse it as BGR, it won't appear the same. Shouldn't this happen with sound as well?

My question is, do these values matter? Should I give the user of my engine the ability to use all the formats listed or can I safely omit some?

 

Thank you.

0

Share this post


Link to post
Share on other sites

Mix_OpenAudio is the output format, but sounds have their own input format. To use a graphics analogy, it's perfectly okay to have a 24bit RGB frame buffer even when you load and render 8 bit palettised GIFs, as long as the system knows how to convert between them. This is what SDL_mixer does for you.

 

In practice it's rare to come across any file formats in use other than WAV, MP3, and OGG (although FLAC is arguably a good one to have) and your output format should almost always be 44khz, 16bit (signed) output. (SDL docs say 22Khz but I wouldn't agree.)

2

Share this post


Link to post
Share on other sites

Mix_OpenAudio is the output format, but sounds have their own input format. To use a graphics analogy, it's perfectly okay to have a 24bit RGB frame buffer even when you load and render 8 bit palettised GIFs, as long as the system knows how to convert between them. This is what SDL_mixer does for you.

 

In practice it's rare to come across any file formats in use other than WAV, MP3, and OGG (although FLAC is arguably a good one to have) and your output format should almost always be 44khz, 16bit (signed) output. (SDL docs say 22Khz but I wouldn't agree.)

 

Hmm, I see. So the output format only concerns the OS and whatever audio middleware it uses and not the actual sound. I'm currently loading support for WAV, MP3, FLAC and OGG in the mixer, and the frequency, chunk size and channel are all modifiable by the user, it was only the output format I was unsure about. So I guess I just fix the output format to 16bit signed?

Also, why are you saying "almost always"? Would I be "safe" (or at least "relatively safe") by fixing it to 16bit signed? Sorry for being pedantic, but this game engine is my thesis and I'd like to justify various design and implementation decisions I make, plus it never hurts to learn more about something. Does ALSA and whatever middleware Windows uses accept 16bit signed samples as their default?

Thanks again for your answer.

0

Share this post


Link to post
Share on other sites

The 'middleware' here is SDL_mixer. :)  That outputs to the OS via one of the various drivers - on Windows that's probably WASAPI, or maybe DirectSound, or ASIO. I think there's a way to force SDL_mixer to choose one, but I forget how. All of them support standard formats like 44/16 anyway, so you'll have no problem with that output setting. The differences between the driver models are in how they support multiple programs (e.g. do they implement their own mixer?) and the way in which you use them (some might require data to be pushed in periodically, others will issue a callback requesting data), but this is all one level of abstraction away from you thanks to SDL.

 

Some people might argue you can get away with 22khz output, but I'd say you lose a bit of high-end frequencies that way, so don't do that. And some people have their audio interfaces set to use 24bit output, which is nice to have - but your 16bit output will work fine with that anyway (it just ignores the least significant 8 bits). I don't know if SDL_mixer supports 24bit output but it's no big deal if not.

 

Stereo 44KHz 16 bit signed output is a standard because that is the format for standard CD audio; as such, almost every file format supports that natively, and any consumer level computer audio device (e.g. sound cards) will be configured to accept it, along with 48Khz for DVD playback.

 

ALSA is an audio framework for Linux, which is sort-of-like WASAPI or ASIO or whatever, but arguably worse than all of them. (Linux audio is a massive mess and has always been that way.)

Edited by Kylotan
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0