Created
April 2, 2020 10:35
-
-
Save rdeioris/954deba775e82ed858f8bcbebb9b3ccb to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Aiv.Fast2D; | |
using Aiv.Audio; | |
namespace LearningAudio | |
{ | |
class Program | |
{ | |
// 1 2 3 4 5 | |
// 3 3 3 3 3 -> 5 3 -> RLE (Run Length Encoding) | |
// 44100 -> 44100 16bit (short) * 2 (stereo) | |
// 48000 -> | |
// 96000 -> | |
// 128000 -> | |
// LOSSLESS WAV (WAVE/RIFF) | |
// LOSSY | |
// xiph.org vorbis -> music flac -> voice theora -> video 8000 -> speex voice (8000) | |
// opus | |
static void Main(string[] args) | |
{ | |
Window window = new Window(512, 512, "Audio Test"); | |
foreach (string deviceName in AudioDevice.Devices) | |
{ | |
Console.WriteLine(deviceName); | |
} | |
Console.WriteLine("Current Device: " + AudioDevice.CurrentDevice.Name); | |
AudioSource source001 = new AudioSource(); | |
AudioClip clip001 = new AudioClip("Assets/bubble_bobble.ogg"); | |
AudioSource source002 = new AudioSource(); | |
AudioClip clip002 = new AudioClip("Assets/laser.wav"); | |
AudioDevice.CurrentDevice.Volume = 0.5f; | |
source001.Volume = 1f; | |
source002.Volume = 1; | |
//source001.Pitch = 0.5f; | |
//source001.Play(clip001, true); | |
/*AudioBuffer buffer = new AudioBuffer(); | |
clip001.LoadToBuffer(buffer, 100); | |
short[] data = clip001.ReadSamples16(clip001.Samples); | |
//source002.Enqueue(...) */ | |
while (window.IsOpened) | |
{ | |
Console.WriteLine(source001.ByteOffset); | |
if (window.GetKey(KeyCode.Up)) | |
source001.Volume += 0.05f; | |
if (window.GetKey(KeyCode.Down)) | |
source001.Volume -= 0.05f; | |
if (window.GetKey(KeyCode.Space) && !source002.IsPlaying) | |
source002.Play(clip002); | |
if (window.deltaTime > 0) | |
source001.Stream(clip001, window.deltaTime); | |
if (window.GetKey(KeyCode.P)) | |
source001.Pause(); | |
if (window.GetKey(KeyCode.R)) | |
source001.Resume(); | |
window.Update(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment