Skip to content

Commit

Permalink
Merge pull request #6 from hybridmachine/FFT_Filters
Browse files Browse the repository at this point in the history
Fft filters
  • Loading branch information
hybridmachine authored Nov 23, 2019
2 parents 9bb4b62 + f1c859b commit 84bc4ab
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Signals And Transforms/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
xmlns:ribbon="clr-namespace:System.Windows.Controls.Ribbon;assembly=System.Windows.Controls.Ribbon"
mc:Ignorable="d"
Title="Signals And Transforms" Height="768" Width="1380">
<Grid x:Name="LayoutRoot">
<Grid x:Name="LayoutRoot" AllowDrop="True" Drop="LayoutRoot_Drop">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
Expand Down
35 changes: 32 additions & 3 deletions Signals And Transforms/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,39 @@ private void MenuItemLoad_Click(object sender, RoutedEventArgs e)
openFileDialog.Filter = $"{Properties.Resources.DATABASE_FILES} (*{Properties.Resources.WORKBOOK_FILE_EXTENSION})|*{Properties.Resources.WORKBOOK_FILE_EXTENSION}|{Properties.Resources.ALL_FILES} (*.*)|*.*";
if (openFileDialog.ShowDialog() == true)
{
// Make active
WorkBookManager.Manager().Load(openFileDialog.FileName, true);
SetActiveWorkbookTitle();
SetActiveWorkbook(openFileDialog.FileName);
}
}

/// <summary>
/// Handle the user action of dropping a workbook file onto the app to open. If it
/// isn't a workbook file (ending in the WORKBOOK_FILE_EXTENSION) then it is ignored
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LayoutRoot_Drop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
// Note that you can have more than one file.
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
string file = files[0];
// Make active
if (file.EndsWith(Properties.Resources.WORKBOOK_FILE_EXTENSION))
{
SetActiveWorkbook(file);
}
}
}

/// <summary>
/// Open the workbook specified in the file pathname variable and set to active workbook
/// </summary>
/// <param name="file"></param>
private void SetActiveWorkbook(string file)
{
WorkBookManager.Manager().Load(file, true);
SetActiveWorkbookTitle();
}
}
}
5 changes: 5 additions & 0 deletions Signals And Transforms/Models/WorkBook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public Signal SumOfSources()
{
List<Signal> signals = new List<Signal>(Signals.Values);
Signal baseSignal = signals.Where(sig => sig.Type == SignalType.Source).FirstOrDefault();
if (baseSignal == null)
{
return null;
}

Signal workbookSourceSignal = new Signal();
workbookSourceSignal.Name = "Source";
workbookSourceSignal.SamplingHZ = baseSignal.SamplingHZ;
Expand Down
5 changes: 5 additions & 0 deletions Signals And Transforms/View Models/ConvolutionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public void PlotData()
{

Signal workbookSourceSignal = manager.ActiveWorkBook().SumOfSources();
if (workbookSourceSignal == null)
{
return;
}

SignalPlotPoints = new List<DataPoint>(workbookSourceSignal.Samples.Count);

for (int idx = 0; idx < workbookSourceSignal.Samples.Count; idx++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ public void PlotSignals()
FrequencyHistogram = new List<DataPoint>(512);

Signal workbookSourceSignal = workBookManager.ActiveWorkBook().SumOfSources();

if (workbookSourceSignal == null)
{
return;
}

// Test data for now
for (int idx=0; idx<workbookSourceSignal.Samples.Count;idx++)
{
Expand Down

0 comments on commit 84bc4ab

Please sign in to comment.