-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch audio playback to NAudio; clarify Mode function names; fix jso…
…n reader/writer to suport float type
- Loading branch information
Showing
15 changed files
with
74 additions
and
66 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
using System; | ||
using System.Windows.Threading; | ||
|
||
namespace SierraHOTAS.Models | ||
{ | ||
public interface IMediaPlayer | ||
{ | ||
void Play(); | ||
void Close(); | ||
void Open(Uri source); | ||
Dispatcher Dispatcher { get; } | ||
bool IsMuted { get; set; } | ||
double Volume { get; set; } | ||
TimeSpan Position { get; set; } | ||
void Open(string sourceFilePath); | ||
float Volume { get; set; } | ||
long Position { get; set; } | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,45 @@ | ||
using System; | ||
using NAudio.Wave; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Windows.Media; | ||
using System.Windows.Threading; | ||
|
||
namespace SierraHOTAS.Models | ||
{ | ||
[ExcludeFromCodeCoverage] | ||
public class MediaPlayerWrapper : IMediaPlayer | ||
{ | ||
private readonly MediaPlayer _mediaPlayer; | ||
private readonly WaveOutEvent _outputDevice; | ||
private AudioFileReader _audioFile; | ||
|
||
public MediaPlayerWrapper(MediaPlayer mediaPlayer) | ||
public MediaPlayerWrapper(WaveOutEvent outputDevice) | ||
{ | ||
_mediaPlayer = mediaPlayer; | ||
_outputDevice = outputDevice; | ||
} | ||
|
||
public void Play() | ||
{ | ||
_mediaPlayer.Play(); | ||
_outputDevice.Play(); | ||
} | ||
|
||
public void Close() | ||
{ | ||
_mediaPlayer.Close(); | ||
_audioFile.Close(); | ||
} | ||
|
||
public void Open(Uri source) | ||
public void Open(string sourceFilePath) | ||
{ | ||
_mediaPlayer.Open(source); | ||
_audioFile = new AudioFileReader(sourceFilePath); | ||
_outputDevice.Init(_audioFile); | ||
} | ||
|
||
public Dispatcher Dispatcher => _mediaPlayer.Dispatcher; | ||
|
||
|
||
public bool IsMuted | ||
{ | ||
get => _mediaPlayer.IsMuted; | ||
set => _mediaPlayer.IsMuted = value; | ||
} | ||
|
||
public double Volume | ||
public float Volume | ||
{ | ||
get => _mediaPlayer.Volume; | ||
set => _mediaPlayer.Volume = value; | ||
get => _outputDevice.Volume; | ||
set => _outputDevice.Volume = value; | ||
} | ||
|
||
public TimeSpan Position | ||
public long Position | ||
{ | ||
get => _mediaPlayer.Position; | ||
set => _mediaPlayer.Position = value; | ||
get => _audioFile.Position; | ||
set => _audioFile.Position = value; | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,10 @@ public int Value | |
} | ||
} | ||
|
||
public Segment() | ||
{ | ||
} | ||
|
||
public Segment(int id, int value) | ||
{ | ||
Id = id; | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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