From 7bf6a712ccb4abe059bcbb739664ac1cadcf0b22 Mon Sep 17 00:00:00 2001 From: raysan5 Date: Sun, 5 Feb 2017 03:15:43 +0100 Subject: Remove rlua from raylib main repo Moved to own repo at https://github.com/raysan5/raylib-lua --- examples/audio_raw_stream.lua | 97 ------------------------------------------- 1 file changed, 97 deletions(-) delete mode 100644 examples/audio_raw_stream.lua (limited to 'examples/audio_raw_stream.lua') diff --git a/examples/audio_raw_stream.lua b/examples/audio_raw_stream.lua deleted file mode 100644 index 070984f9..00000000 --- a/examples/audio_raw_stream.lua +++ /dev/null @@ -1,97 +0,0 @@ -------------------------------------------------------------------------------------------- --- --- raylib [audio] example - Raw audio streaming --- --- NOTE: This example requires OpenAL Soft library installed --- --- This example has been created using raylib 1.6 (www.raylib.com) --- raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) --- --- Copyright (c) 2014-2016 Ramon Santamaria (@raysan5) --- -------------------------------------------------------------------------------------------- - -MAX_SAMPLES = 20000 -DEG2RAD = math.pi/180.0 - --- Initialization -------------------------------------------------------------------------------------------- -local screenWidth = 800 -local screenHeight = 450 - -InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw audio streaming") - -InitAudioDevice() -- Initialize audio device - --- Init raw audio stream (sample rate: 22050, sample size: 32bit-float, channels: 1-mono) -local stream = InitAudioStream(22050, 32, 1) - --- Fill audio stream with some samples (sine wave) -local data = {} - -for i = 1, MAX_SAMPLES do - data[i] = math.sin(((2*math.pi*i)/2)*DEG2RAD) -end - --- NOTE: The generated MAX_SAMPLES do not fit to close a perfect loop --- for that reason, there is a clip everytime audio stream is looped - -PlayAudioStream(stream) - -local totalSamples = MAX_SAMPLES -local samplesLeft = totalSamples - -local position = Vector2(0, 0) - -SetTargetFPS(30) -- Set our game to run at 30 frames-per-second -------------------------------------------------------------------------------------------- - --- Main game loop -while not WindowShouldClose() do -- Detect window close button or ESC key - -- Update - --------------------------------------------------------------------------------------- - - -- Refill audio stream if required - if (IsAudioBufferProcessed(stream)) then - local numSamples = 0 - - if (samplesLeft >= 4096) then numSamples = 4096 - else numSamples = samplesLeft end - - UpdateAudioStream(stream, data + (totalSamples - samplesLeft), numSamples) - - samplesLeft = samplesLeft - numSamples - - -- Reset samples feeding (loop audio) - if (samplesLeft <= 0) then samplesLeft = totalSamples end - end - --------------------------------------------------------------------------------------- - - -- Draw - --------------------------------------------------------------------------------------- - BeginDrawing() - - ClearBackground(RAYWHITE) - - DrawText("SINE WAVE SHOULD BE PLAYING!", 240, 140, 20, LIGHTGRAY) - - -- NOTE: Draw a part of the sine wave (only screen width) - for i = 1, GetScreenWidth() do - position.x = (i - 1) - position.y = 250 + 50*data[i] - - DrawPixelV(position, RED) - end - - EndDrawing() - --------------------------------------------------------------------------------------- -end - --- De-Initialization -------------------------------------------------------------------------------------------- -CloseAudioStream(stream) -- Close raw audio stream and delete buffers from RAM - -CloseAudioDevice() -- Close audio device (music streaming is automatically stopped) - -CloseWindow() -- Close window and OpenGL context -------------------------------------------------------------------------------------------- \ No newline at end of file -- cgit v1.2.3