mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-07-16 15:37:31 +00:00
Renamed TestPlayback.cs to Playback.cs
This commit is contained in:
parent
5f4a639ebd
commit
ddf7f3ac34
|
@ -14,17 +14,17 @@ using OpenTK.Audio;
|
||||||
namespace Examples
|
namespace Examples
|
||||||
{
|
{
|
||||||
[Example("Playback", ExampleCategory.OpenAL)]
|
[Example("Playback", ExampleCategory.OpenAL)]
|
||||||
public partial class Playback
|
public class Playback
|
||||||
{
|
{
|
||||||
|
const string filename = "Data\\Audio\\the_ring_that_fell.wav";
|
||||||
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
const string file = "Data\\Audio\\the_ring_that_fell.wav";
|
|
||||||
|
|
||||||
AudioContext context = new AudioContext();
|
AudioContext context = new AudioContext();
|
||||||
|
|
||||||
using (SoundReader sound = new SoundReader(file))
|
using (SoundReader sound = new SoundReader(filename))
|
||||||
{
|
{
|
||||||
Console.WriteLine("Testing WaveReader({0}).ReadToEnd()", file);
|
Console.WriteLine("Testing WaveReader({0}).ReadToEnd()", filename);
|
||||||
|
|
||||||
int buffer = AL.GenBuffer();
|
int buffer = AL.GenBuffer();
|
||||||
int source = AL.GenSource();
|
int source = AL.GenSource();
|
||||||
|
@ -54,61 +54,5 @@ namespace Examples
|
||||||
sound.Dispose();
|
sound.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region static void TestWaveReaderStreaming(string filename)
|
|
||||||
|
|
||||||
static void TestWaveReaderStreaming(string filename)
|
|
||||||
{
|
|
||||||
using (SoundReader sound = new SoundReader(filename))
|
|
||||||
{
|
|
||||||
int[] buffers = AL.GenBuffers(2);
|
|
||||||
int source = AL.GenSource();
|
|
||||||
int state;
|
|
||||||
|
|
||||||
Console.WriteLine("Testing WaveReader({0}).ReadSamples()", filename);
|
|
||||||
|
|
||||||
Console.Write("Playing");
|
|
||||||
|
|
||||||
//new Thread().Start(buffers
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Query the source to find out when it stops playing.
|
|
||||||
do
|
|
||||||
{
|
|
||||||
Thread.Sleep(100);
|
|
||||||
Console.Write(".");
|
|
||||||
AL.GetSource(source, ALGetSourcei.SourceState, out state);
|
|
||||||
} while ((ALSourceState)state == ALSourceState.Playing);
|
|
||||||
|
|
||||||
Console.WriteLine();
|
|
||||||
|
|
||||||
AL.SourceStop(source);
|
|
||||||
AL.DeleteSources(ref source);
|
|
||||||
AL.DeleteBuffers(buffers);
|
|
||||||
|
|
||||||
sound.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SoundStreamer
|
|
||||||
{
|
|
||||||
public SoundStreamer(SoundReader sound, int source, int[] buffers)
|
|
||||||
{
|
|
||||||
while (!sound.EndOfFile)
|
|
||||||
{
|
|
||||||
int processed_count;
|
|
||||||
AL.GetSource(source, ALGetSourcei.BuffersProcessed, out processed_count);
|
|
||||||
while (processed_count-- > 0)
|
|
||||||
{
|
|
||||||
int buffer = AL.SourceUnqueueBuffer(source);
|
|
||||||
AL.BufferData(buffer, sound.ReadSamples(8096));
|
|
||||||
AL.SourceQueueBuffer(source, buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue