Mana
Loading...
Searching...
No Matches
soundeffect.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2004-2009 The Mana World Development Team
4 * Copyright (C) 2009-2012 The Mana Developers
5 *
6 * This file is part of The Mana Client.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
23
24#include "log.h"
25
27{
28 Mix_FreeChunk(mChunk);
29}
30
32{
33 // Load the music data and free the RWops structure
34 if (Mix_Chunk *soundEffect = Mix_LoadWAV_RW(rw, 1))
35 {
36 return new SoundEffect(soundEffect);
37 }
38
39 Log::info("Error, failed to load sound effect: %s", Mix_GetError());
40 return nullptr;
41}
42
43int SoundEffect::play(int loops, int volume, int channel)
44{
45 Mix_VolumeChunk(mChunk, volume);
46 return Mix_PlayChannel(channel, mChunk, loops);
47}
Defines a class for loading and storing sound effects.
Definition soundeffect.h:32
~SoundEffect() override
int play(int loops, int volume, int channel=-1)
Plays the sample.
Mix_Chunk * mChunk
Definition soundeffect.h:61
static SoundEffect * load(SDL_RWops *rw)
Loads a sample from a buffer in memory.
void info(const char *log_text,...) LOG_PRINTF_ATTR