Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the application runnable in UNIX. #22

Merged
merged 1 commit into from
Mar 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions Audio/MockSongPlayer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using Jammit.Model;
using NAudio.Wave;

namespace Jammit.Audio
{
public class MockSongPlayer : ISongPlayer
{
private TimeSpan _position;
private PlaybackState _playbackState;
private readonly WaveMixerStream32 _mixer;

public MockSongPlayer(ISong s)
{
_mixer = new WaveMixerStream32();
_mixer.AddInputStream(new WaveChannel32(new ClickTrackStream(s.Beats)));
}

#region ISongPlayer members

public void Play()
{
_playbackState = PlaybackState.Playing;
}

public void Pause()
{
_playbackState = PlaybackState.Paused;
}

public void Stop()
{
_playbackState = PlaybackState.Stopped;
}

public long PositionSamples => _position.Ticks / 8;

public TimeSpan Position
{
get { return _position; }
set { _position = value; }
}

public TimeSpan Length => _mixer.TotalTime;

public PlaybackState State => _playbackState;

public int Channels => 0;

public string GetChannelName(int channel) => $"Mock Channel[{channel}]";

public void SetChannelVolume(int channel, float volume) { }

public float GetChannelVolume(int channel) => 0.0f;

#endregion
}
}
1 change: 1 addition & 0 deletions Jam.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Audio\MockSongPlayer.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
Expand Down
34 changes: 34 additions & 0 deletions Jam.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,38 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0
$0.DotNetNamingPolicy = $1
$1.DirectoryNamespaceAssociation = None
$1.ResourceNamePolicy = FileFormatDefault
$0.TextStylePolicy = $2
$2.FileWidth = 120
$2.TabWidth = 2
$2.IndentWidth = 2
$2.inheritsSet = VisualStudio
$2.inheritsScope = text/plain
$2.scope = text/x-csharp
$0.CSharpFormattingPolicy = $3
$3.IndentSwitchSection = True
$3.NewLinesForBracesInProperties = True
$3.NewLinesForBracesInAccessors = True
$3.NewLinesForBracesInAnonymousMethods = True
$3.NewLinesForBracesInControlBlocks = True
$3.NewLinesForBracesInAnonymousTypes = True
$3.NewLinesForBracesInObjectCollectionArrayInitializers = True
$3.NewLinesForBracesInLambdaExpressionBody = True
$3.NewLineForElse = True
$3.NewLineForCatch = True
$3.NewLineForFinally = True
$3.NewLineForMembersInObjectInit = True
$3.NewLineForMembersInAnonymousTypes = True
$3.NewLineForClausesInQuery = True
$3.SpacingAfterMethodDeclarationName = False
$3.SpaceAfterMethodCallName = False
$3.SpaceBeforeOpenSquareBracket = False
$3.inheritsSet = Mono
$3.inheritsScope = text/x-csharp
$3.scope = text/x-csharp
EndGlobalSection
EndGlobal
3 changes: 3 additions & 0 deletions Model/FolderSong.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public ScoreNodes GetNotationData(string trackName, string notationType)

public ISongPlayer GetSongPlayer()
{
if (System.Type.GetType("Mono.Runtime") != null)
return new MockSongPlayer(this);

return new JammitNAudioSongPlayer(this);
}

Expand Down
3 changes: 3 additions & 0 deletions Model/ZipSong.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public List<Image> GetTablature(Track t)

public ISongPlayer GetSongPlayer()
{
if (System.Type.GetType("Mono.Runtime") != null)
return new MockSongPlayer(this);

return new JammitNAudioSongPlayer(this);
}

Expand Down