Skip to content

Commit

Permalink
Rearrange project files
Browse files Browse the repository at this point in the history
  • Loading branch information
jurihock committed May 6, 2024
1 parent 194f635 commit 7ff2d59
Show file tree
Hide file tree
Showing 48 changed files with 130 additions and 99 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ help:
@echo clean

build:
@cmake -DCMAKE_BUILD_TYPE=$(CFG) -S $(SRC)/spectrality-library -B $(DST)/spectrality-library
@cmake --build $(DST)/spectrality-library
@dotnet build $(SRC)/spectrality --configuration $(CFG)
@cp -v $(DST)/spectrality-library/spectrality/*.dll $(DST)/spectrality/bin/$(CFG)
@cmake -DCMAKE_BUILD_TYPE=$(CFG) -S $(SRC)/Spectrality.Library -B $(DST)/Spectrality.Library
@cmake --build $(DST)/Spectrality.Library
@dotnet build $(SRC)/Spectrality --configuration $(CFG)
@cp -v $(DST)/Spectrality.Library/spectrality/*.dll $(DST)/Spectrality/bin/$(CFG)

publish: build
@dotnet publish $(SRC)/spectrality --configuration $(CFG)
@cp -v $(DST)/spectrality-library/spectrality/*.dll $(DST)/spectrality/bin/$(CFG)/publish
@dotnet publish $(SRC)/Spectrality --configuration $(CFG)
@cp -v $(DST)/Spectrality.Library/spectrality/*.dll $(DST)/Spectrality/bin/$(CFG)/publish

run: build
@dotnet run --project $(SRC)/spectrality --configuration $(CFG)
@dotnet run --project $(SRC)/Spectrality --configuration $(CFG)

clean:
@rm -rf $(DST)
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<BaseOutputPath>$(MSBuildThisFileDirectory)\..\..\build\$(MSBuildProjectName.ToLower())\bin\</BaseOutputPath>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)\..\..\build\$(MSBuildProjectName.ToLower())\obj\</BaseIntermediateOutputPath>
<BaseOutputPath>$(MSBuildThisFileDirectory)\..\build\$(MSBuildProjectName)\bin\</BaseOutputPath>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)\..\build\$(MSBuildProjectName)\obj\</BaseIntermediateOutputPath>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using Spectrality.Extensions;

namespace Spectrality.DSP;
namespace Spectrality.Analysis;

public sealed class QDFT : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using Spectrality.Misc;
using Spectrality.Models;

namespace Spectrality.DSP;
namespace Spectrality.Analysis;

public class SpectrumAnalyzer
public sealed class SpectrumAnalyzer
{
private readonly struct PrepareBag
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
using System.Text;
using Spectrality.Extensions;

namespace Spectrality.IO;
namespace Spectrality.Audio;

public class AudioFileReader
public sealed class AudioFileReader
{
private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ public sealed class MemoryMappedDatagram : IDatagram
{
private readonly int dx, dy;

private MemoryMappedFile File { get; init; }
private MemoryMappedViewAccessor View { get; init; }

public string Path { get; private init; }
public MemoryMappedFile File { get; private init; }
public MemoryMappedViewAccessor View { get; private init; }

public int Width => X.Length;
public int Height => Y.Length;
Expand Down
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions src/Spectrality.Core/Spectrality.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="5.3.1" />
</ItemGroup>
</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
using System.Threading.Tasks;
using OxyPlot;
using OxyPlot.Series;
using Spectrality.Plot.Manipulators;
using Spectrality.Plot.Series;

namespace Spectrality.Plot;
namespace Spectrality.Plot.Controllers;

public sealed class SyncPlotController : PlotController
{
Expand Down Expand Up @@ -60,11 +62,11 @@ private void BindSync()

private void OnResetAllAxes()
{
var filter = (Series series) =>
var filter = (OxyPlot.Series.Series series) =>
(series is ISyncSeries) &&
(series is XYAxisSeries);

var cast = (Series? series) =>
var cast = (OxyPlot.Series.Series? series) =>
(XYAxisSeries)(series ?? throw new InvalidOperationException());

var slaves = SyncPlotModels
Expand Down Expand Up @@ -120,11 +122,11 @@ private void OnMasterPanZoomChanged(object? sender, SyncPanZoomEventArgs args)
return;
}

var filter = (Series series) =>
var filter = (OxyPlot.Series.Series series) =>
(series is ISyncSeries) &&
(series is XYAxisSeries);

var cast = (Series? series) =>
var cast = (OxyPlot.Series.Series? series) =>
(XYAxisSeries)(series ?? throw new InvalidOperationException());

var slaves = SyncPlotModels
Expand Down Expand Up @@ -174,11 +176,11 @@ private void OnMasterTrackerChanged(object? sender, SyncTrackerEventArgs args)
return;
}

var filter = (Series series) =>
var filter = (OxyPlot.Series.Series series) =>
(series is ISyncSeries) &&
(series is XYAxisSeries);

var cast = (Series? series) =>
var cast = (OxyPlot.Series.Series? series) =>
(XYAxisSeries)(series ?? throw new InvalidOperationException());

var slaves = SyncPlotModels
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using OxyPlot;
using Spectrality.Misc;

namespace Spectrality.Extensions;
namespace Spectrality.Plot.Extensions;

public static class BitmapExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using OxyPlot;

namespace Spectrality.Plot;
namespace Spectrality.Plot.Manipulators;

public sealed class SyncPanZoomEventArgs(double minX, double maxX, double minY, double maxY) : EventArgs
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Linq;
using OxyPlot;
using OxyPlot.Series;
using Spectrality.Plot.Series;

namespace Spectrality.Plot;
namespace Spectrality.Plot.Manipulators;

public sealed class SyncTrackerEventArgs(DataPoint? point) : EventArgs
{
Expand All @@ -12,7 +12,7 @@ public sealed class SyncTrackerEventArgs(DataPoint? point) : EventArgs

public sealed class SyncTrackerManipulator : MouseManipulator
{
private readonly Series? TrackableSeries;
private readonly OxyPlot.Series.Series? TrackableSeries;
private readonly bool IsTrackerEnabled;

public event EventHandler<SyncTrackerEventArgs>? TrackerChanged;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using OxyPlot;
using OxyPlot.Axes;
using Spectrality.Models;
using Spectrality.Plot.Series;

namespace Spectrality.Plot;
namespace Spectrality.Plot.Models;

public class SpectrogramPlotModel : PlotModel
public sealed class SpectrogramPlotModel : PlotModel
{
public LinearAxis AxisX { get; init; }
public LogarithmicAxis AxisY { get; init; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
using Spectrality.Misc;
using Spectrality.Models;

namespace Spectrality.Plot;
namespace Spectrality.Plot.Renderers;

public class ChromesthesiaSpectrogramBitmap : ISpectrogramBitmap
public sealed class ChromesthesiaSpectrogramRenderer : ISpectrogramRenderer
{
public (double, double) Limit { get; private set; }
public double Gamma { get; private set; }
public double Brightness { get; private set; }
public double Saturation { get; private set; }

public ChromesthesiaSpectrogramBitmap()
public ChromesthesiaSpectrogramRenderer()
{
Limit = (-120, 0);
Gamma = 2;
Brightness = 1;
Saturation = -0.5;
}

public ChromesthesiaSpectrogramBitmap((double, double) limit,
public ChromesthesiaSpectrogramRenderer((double, double) limit,
double gamma = 1,
double brightness = 1,
double saturation = 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Spectrality.Models;

namespace Spectrality.Plot;
namespace Spectrality.Plot.Renderers;

public interface ISpectrogramBitmap
public interface ISpectrogramRenderer
{
void RenderBitmap(Spectrogram spectrogram);
}
5 changes: 5 additions & 0 deletions src/Spectrality.Plot/Series/ISyncSeries.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Spectrality.Plot.Series;

public interface ISyncSeries
{
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
using System;
using OxyPlot;
using OxyPlot.Series;
using Spectrality.Extensions;
using Spectrality.Misc;
using Spectrality.Models;
using Spectrality.Plot.Extensions;
using Spectrality.Plot.Renderers;
using Spectrality.Plot.Transforms;

namespace Spectrality.Plot;
namespace Spectrality.Plot.Series;

public class SpectrogramSeries : XYAxisSeries, ISyncSeries
public sealed class SpectrogramSeries : XYAxisSeries, ISyncSeries
{
private readonly object ImageSyncRoot = new();

private ISpectrogramBitmap SpectrogramBitmap { get; set; }
private ISpectrogramRenderer SpectrogramRenderer { get; set; }
private ICoordinateTransformation<DataPoint> CoordinateTransformation { get; set; }

private Spectrogram? spectrogram;
Expand All @@ -33,7 +35,7 @@ public Spectrogram? Spectrogram
new LinearCoordinateTransformation(spectrogram.Value.Data.X),
new LogarithmicCoordinateTransformation(spectrogram.Value.Data.Y));

SpectrogramBitmap.RenderBitmap(spectrogram.Value);
SpectrogramRenderer.RenderBitmap(spectrogram.Value);

image = spectrogram.Value.Bitmap.ToOxyImage();
}
Expand All @@ -54,7 +56,7 @@ private OxyImage? Image

public SpectrogramSeries()
{
SpectrogramBitmap = new ChromesthesiaSpectrogramBitmap();
SpectrogramRenderer = new ChromesthesiaSpectrogramRenderer();

CoordinateTransformation = new CartesianCoordinateTransformation(
new LinearCoordinateTransformation(),
Expand All @@ -70,7 +72,7 @@ public void Update()
return;
}

SpectrogramBitmap.RenderBitmap(spectrogram.Value);
SpectrogramRenderer.RenderBitmap(spectrogram.Value);

lock (ImageSyncRoot)
{
Expand Down
13 changes: 13 additions & 0 deletions src/Spectrality.Plot/Spectrality.Plot.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Oxyplot.Avalonia" Version="2.1.0-Avalonia11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Spectrality.Core\Spectrality.Core.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using OxyPlot;

namespace Spectrality.Plot;
namespace Spectrality.Plot.Transforms;

public class CartesianCoordinateTransformation : ICoordinateTransformation<DataPoint>
public sealed class CartesianCoordinateTransformation : ICoordinateTransformation<DataPoint>
{
public ICoordinateTransformation<double> TransformX { get; private set; }
public ICoordinateTransformation<double> TransformY { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Spectrality.Plot;
namespace Spectrality.Plot.Transforms;

public interface ICoordinateTransformation<T>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Linq;

namespace Spectrality.Plot;
namespace Spectrality.Plot.Transforms;

public class LinearCoordinateTransformation : ICoordinateTransformation<double>
public sealed class LinearCoordinateTransformation : ICoordinateTransformation<double>
{
public double Slope { get; private set; }
public double Intercept { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Linq;

namespace Spectrality.Plot;
namespace Spectrality.Plot.Transforms;

public class LogarithmicCoordinateTransformation : ICoordinateTransformation<double>
public sealed class LogarithmicCoordinateTransformation : ICoordinateTransformation<double>
{
public double Slope { get; private set; }
public double Intercept { get; private set; }
Expand Down
34 changes: 34 additions & 0 deletions src/Spectrality.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spectrality", "Spectrality\Spectrality.csproj", "{B4939BCC-384B-42B5-9635-D1C4DECE20FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spectrality.Core", "Spectrality.Core\Spectrality.Core.csproj", "{06483905-932E-4A46-A06E-BEA8D42E0408}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Spectrality.Plot", "Spectrality.Plot\Spectrality.Plot.csproj", "{7428452C-8AA5-406B-A8BA-D03DEE616D27}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B4939BCC-384B-42B5-9635-D1C4DECE20FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B4939BCC-384B-42B5-9635-D1C4DECE20FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4939BCC-384B-42B5-9635-D1C4DECE20FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4939BCC-384B-42B5-9635-D1C4DECE20FA}.Release|Any CPU.Build.0 = Release|Any CPU
{06483905-932E-4A46-A06E-BEA8D42E0408}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06483905-932E-4A46-A06E-BEA8D42E0408}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06483905-932E-4A46-A06E-BEA8D42E0408}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06483905-932E-4A46-A06E-BEA8D42E0408}.Release|Any CPU.Build.0 = Release|Any CPU
{7428452C-8AA5-406B-A8BA-D03DEE616D27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7428452C-8AA5-406B-A8BA-D03DEE616D27}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7428452C-8AA5-406B-A8BA-D03DEE616D27}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7428452C-8AA5-406B-A8BA-D03DEE616D27}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Loading

0 comments on commit 7ff2d59

Please sign in to comment.