-
Notifications
You must be signed in to change notification settings - Fork 29
Add Sound support #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RobLoach
wants to merge
7
commits into
tsoding:main
Choose a base branch
from
RobLoach:sound
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
72690c8
sound: Add audio_sound_loading assets
RobLoach 8376324
sound: Add Sound support
RobLoach ca36ed6
sound: Add audio_sound_loading.c example
RobLoach 4d8ccdd
sound: Add compiled audio_sound_loading.wasm
RobLoach f6aba81
sound: Fix documentation around Sound::frameCount
RobLoach b2e2820
sound: Fix audio variable name
RobLoach 015375f
Merge branch 'main' into sound
RobLoach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,83 @@ | ||
/******************************************************************************************* | ||
* | ||
* raylib [audio] example - Sound loading and playing | ||
* | ||
* Example originally created with raylib 1.1, last time updated with raylib 3.5 | ||
* | ||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, | ||
* BSD-like license that allows static linking with closed source software | ||
* | ||
* Copyright (c) 2014-2024 Ramon Santamaria (@raysan5) | ||
* | ||
********************************************************************************************/ | ||
|
||
#include "raylib.h" | ||
|
||
void raylib_js_set_entry(void (*entry)(void)); | ||
|
||
Sound fxWav; | ||
Sound fxOgg; | ||
|
||
void GameFrame(void) | ||
{ | ||
// Update | ||
//---------------------------------------------------------------------------------- | ||
if (IsKeyPressed(KEY_SPACE)) PlaySound(fxWav); // Play WAV sound | ||
if (IsKeyPressed(KEY_ENTER)) PlaySound(fxOgg); // Play OGG sound | ||
//---------------------------------------------------------------------------------- | ||
|
||
// Draw | ||
//---------------------------------------------------------------------------------- | ||
BeginDrawing(); | ||
|
||
ClearBackground(RAYWHITE); | ||
|
||
DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY); | ||
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY); | ||
|
||
EndDrawing(); | ||
//---------------------------------------------------------------------------------- | ||
} | ||
|
||
//------------------------------------------------------------------------------------ | ||
// Program main entry point | ||
//------------------------------------------------------------------------------------ | ||
int main(void) | ||
{ | ||
// Initialization | ||
//-------------------------------------------------------------------------------------- | ||
const int screenWidth = 800; | ||
const int screenHeight = 450; | ||
|
||
InitWindow(screenWidth, screenHeight, "raylib [audio] example - sound loading and playing"); | ||
|
||
InitAudioDevice(); // Initialize audio device | ||
|
||
fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file | ||
fxOgg = LoadSound("resources/target.ogg"); // Load OGG audio file | ||
|
||
SetTargetFPS(60); // Set desired framerate (frames-per-second) | ||
//-------------------------------------------------------------------------------------- | ||
|
||
#ifdef PLATFORM_WEB | ||
raylib_js_set_entry(GameFrame); | ||
#else | ||
// Main game loop | ||
while (!WindowShouldClose()) // Detect window close button or ESC key | ||
{ | ||
GameFrame(); | ||
} | ||
|
||
// De-Initialization | ||
//-------------------------------------------------------------------------------------- | ||
UnloadSound(fxWav); // Unload sound data | ||
UnloadSound(fxOgg); // Unload sound data | ||
|
||
CloseAudioDevice(); // Close audio device | ||
|
||
CloseWindow(); // Close window and OpenGL context | ||
//-------------------------------------------------------------------------------------- | ||
#endif | ||
|
||
return 0; | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.