public AudioStream Load(string streamKey, string filename) { if (!File.Exists(filename)) { throw new Exception("Cannot find file " + filename); } if (GetStreamSection(streamKey) != null) { throw new Exception("AudioStream already exists with streamKey " + streamKey); } var audioStream = new Sample { Filename = filename }; var tags = TagHelper.LoadTags(filename); if (tags != null) { if (tags.Gain.HasValue) { audioStream.Gain = tags.Gain.Value; } if (tags.Bpm.HasValue) { audioStream.Bpm = tags.Bpm.Value; } audioStream.Description = TrackHelper.GuessTrackDescription(filename, tags.Artist, tags.Title); } AudioStreamHelper.LoadAudio(audioStream); audioStream.SyncProc = OnSync; AudioStreamHelper.AddToMixer(audioStream, Output); AudioStreamHelper.SetPosition(audioStream, 0); lock (_streamSections) { _streamSections.Add(new AudioStreamSection { Key = streamKey, AudioStream = audioStream, AudioSections = new List <AudioSection>() }); } return(audioStream); }