-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from hozuki/v0.7.8
v0.7.8
- Loading branch information
Showing
13 changed files
with
348 additions
and
244 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "external/SharpAL"] | ||
path = external/SharpAL | ||
url = https://github.com/OpenCGSS/SharpAL.git |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using DereTore.Common; | ||
using NAudio.Wave; | ||
using SharpAL; | ||
|
||
namespace DereTore.Apps.ScoreViewer { | ||
public sealed class AudioManager : DisposableBase { | ||
|
||
public AudioManager() { | ||
_audioDevice = new AudioDevice(); | ||
_audioContext = new AudioContext(_audioDevice); | ||
} | ||
|
||
public AudioDevice AudioDevice => _audioDevice; | ||
|
||
public AudioContext AudioContext => _audioContext; | ||
|
||
public static readonly WaveFormat StandardFormat = new WaveFormat(); | ||
|
||
public static bool NeedsConversion(WaveFormat test, WaveFormat standard) { | ||
return test.SampleRate != standard.SampleRate || | ||
test.BitsPerSample != standard.BitsPerSample || | ||
test.Channels != standard.Channels || | ||
test.Encoding != standard.Encoding; | ||
} | ||
|
||
protected override void Dispose(bool disposing) { | ||
_audioContext?.Dispose(); | ||
_audioDevice?.Dispose(); | ||
|
||
_audioContext = null; | ||
_audioDevice = null; | ||
} | ||
|
||
private AudioDevice _audioDevice; | ||
private AudioContext _audioContext; | ||
|
||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.IO; | ||
|
||
namespace DereTore.Apps.ScoreViewer.Extensions { | ||
public static class StreamExtensions { | ||
|
||
public static byte[] ReadToEnd(this Stream stream) { | ||
return ReadToEnd(stream, 102400); | ||
} | ||
|
||
public static byte[] ReadToEnd(this Stream stream, int bufferSize) { | ||
byte[] data; | ||
var buffer = new byte[bufferSize]; | ||
var length = stream.Length; | ||
|
||
using (var memoryStream = new MemoryStream()) { | ||
var read = 1; | ||
long totalRead = 0; | ||
|
||
while (read > 0) { | ||
read = stream.Read(buffer, 0, bufferSize); | ||
memoryStream.Write(buffer, 0, read); | ||
|
||
totalRead += read; | ||
|
||
// totalread >= length: for WaveOffsetStream | ||
if (read < bufferSize || totalRead >= length) { | ||
break; | ||
} | ||
} | ||
|
||
data = memoryStream.ToArray(); | ||
} | ||
|
||
return data; | ||
} | ||
|
||
} | ||
} |
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
Oops, something went wrong.