-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started implementation of audio loading from SKAP file (#31)
- Loading branch information
1 parent
cc4c5e7
commit 9fc2329
Showing
7 changed files
with
140 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* GNU Sparky --- A 5v5 character-based libre tactical shooter | ||
* Copyright (C) 2024 Wasym A. Alonso | ||
* | ||
* This file is part of Sparky. | ||
* | ||
* Sparky is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Sparky is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Sparky. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#pragma once | ||
|
||
#include <raylib.h> | ||
#include <sk_assetpack.h> | ||
|
||
void sk_audio_init(sk_assetpack *ap); | ||
|
||
Sound sk_audio_load(const char *filename); | ||
|
||
Music sk_audio_stream_load(const char *filename); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* GNU Sparky --- A 5v5 character-based libre tactical shooter | ||
* Copyright (C) 2024 Wasym A. Alonso | ||
* | ||
* This file is part of Sparky. | ||
* | ||
* Sparky is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Sparky is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Sparky. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
#include <sk_log.h> | ||
#include <sk_audio.h> | ||
|
||
static sk_assetpack *skap = 0; | ||
|
||
void sk_audio_init(sk_assetpack *ap) { skap = ap; } | ||
|
||
Sound sk_audio_load(const char *filename) { | ||
#ifndef NDEBUG | ||
return LoadSound(filename); | ||
#else | ||
if (!skap) SK_LOG_ERROR("sk_audio_load :: SKAP was not initialized (maybe forgot to exec `sk_audio_init` ?)"); | ||
Wave wave = {0}; | ||
if (!sk_assetpack_lookup(skap, SK_ASSETPACK_BLOB_KIND_AUDIO, filename, &wave)) { | ||
SK_LOG_ERROR("sk_audio_load :: unable to retrieve audio from SKAP file"); | ||
} | ||
Sound sound = LoadSoundFromWave(wave); | ||
UnloadWave(wave); | ||
return sound; | ||
#endif | ||
} | ||
|
||
Music sk_audio_stream_load(const char *filename) { | ||
#ifndef NDEBUG | ||
return LoadMusicStream(filename); | ||
#else | ||
if (!skap) SK_LOG_ERROR("sk_audio_stream_load :: SKAP was not initialized (maybe forgot to exec `sk_audio_init` ?)"); | ||
Wave wave = {0}; | ||
if (!sk_assetpack_lookup(skap, SK_ASSETPACK_BLOB_KIND_AUDIO, filename, &wave)) { | ||
SK_LOG_ERROR("sk_audio_stream_load :: unable to retrieve audio from SKAP file"); | ||
} | ||
return LoadMusicStreamFromMemory(".mp3", wave.data, wave.frameCount * wave.channels * (wave.sampleSize / 8)); | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters