Skip to content

Instantly share code, notes, and snippets.

@PieroCastillo
Created March 18, 2021 19:33
Show Gist options
  • Save PieroCastillo/93cab159090016346b638753c2cdb10e to your computer and use it in GitHub Desktop.
Save PieroCastillo/93cab159090016346b638753c2cdb10e to your computer and use it in GitHub Desktop.
Minimal Program using SharpAudio
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using SharpAudio.Codec;
namespace SharpAudio.Sample
{
class Program
{
static void Main(string[] args)
{
var engine = AudioEngine.CreateDefault();
string path = "the path of the mp3 file";
if (engine == null)
{
Console.WriteLine("Failed to create an audio backend!");
return;
}
if(!File.Exists(path))
{
Console.WriteLine("The file does not exist.");
return;
}
else
{
Console.WriteLine("The file exists.");
}
var soundStream = new SoundStream(File.OpenRead(path), engine);
soundStream.Volume = 5f;
Console.WriteLine("Loaded Correctly");
soundStream.Play();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment