Skip to content
Permalink
Browse files

db admin: change samplerate/range of continuous annotations (a copy w…

…ill be created)
  • Loading branch information...
tobiasbaur committed Jun 11, 2019
1 parent b6a0a35 commit dbeeab30f44ce67ca2d32c45508164de48b95120
@@ -16,7 +16,7 @@ public partial class MainHandler
{

//Config
public static string BuildVersion = "1.0.5.2";
public static string BuildVersion = "1.0.5.3";
public static MEDIABACKEND MediaBackend = MEDIABACKEND.MEDIAKIT;
public static bool ENABLE_PYTHON = Properties.Settings.Default.EnablePython;

@@ -56,6 +56,7 @@
<Button Style="{StaticResource MyButton}" Name="AddScheme" Content="ADD" Click="AddScheme_Click"/>
<Button Style="{StaticResource MyButton}" Name="DeleteScheme" Content="REM" Click="DeleteScheme_Click"/>
<Button Style="{StaticResource MyButton}" Name="EditScheme" Content="EDIT" Click="EditScheme_Click" />
<Button Style="{StaticResource MyButton}" Name="ResampleScheme" Content="RESAMPLE" Click="ResampleScheme_Click" />
</StackPanel >
<ListBox x:Name="SchemesBox" DockPanel.Dock="Top" Margin="5,0,5,0" SelectionMode="Single" Focusable="True" ToolTip="{Binding SelectedItem, RelativeSource={RelativeSource Self}}" />
</DockPanel>
@@ -485,5 +485,87 @@ private void Window_Closed(object sender, EventArgs e)
{
//DatabaseHandler.UpdateDatabaseLocalLists();
}

private void ResampleScheme_Click(object sender, RoutedEventArgs e)
{

if (SchemesBox.SelectedItem != null)
{
string name = (string)SchemesBox.SelectedItem;
AnnoScheme oldScheme = DatabaseHandler.GetAnnotationScheme(name);
AnnoScheme newScheme = DatabaseHandler.GetAnnotationScheme(name);
if (newScheme.Type != AnnoScheme.TYPE.CONTINUOUS)
{
MessageBox.Show("Only continuous annotations can be resampled");
return;
}



newScheme.Name = newScheme.Name + "_resampled";
AnnoTierNewContinuousSchemeWindow window = new AnnoTierNewContinuousSchemeWindow(ref newScheme);
window.ShowDialog();

if(window.DialogResult == true)
{
if (DatabaseHandler.AddScheme(newScheme))
{

List<DatabaseAnnotation> existingAnnos = DatabaseHandler.GetAnnotations(oldScheme);

if (existingAnnos.Count > 0)
{
AnnoList al_t = DatabaseHandler.LoadAnnoList(existingAnnos[0].Id);
double old_sr = al_t.Scheme.SampleRate;
double factor = 0;

if (old_sr > newScheme.SampleRate)
{
factor = old_sr / newScheme.SampleRate;
}
else if (old_sr < newScheme.SampleRate)
{
factor = newScheme.SampleRate / old_sr;
}

else factor = 1;


if (factor % 1 != 0)
{
MessageBox.Show("New samplerate must be a number divisible by old samplerate.");
return;
}


foreach (DatabaseAnnotation anno in existingAnnos)
{
AnnoList al = DatabaseHandler.LoadAnnoList(anno.Id);
DatabaseHandler.resampleAnnotationtoNewScheme(al, newScheme, al_t.Scheme);

}

GetSchemes();
}
else
{
MessageBox.Show("Scheme created, but no existing Annotations found, nothing was converted.");
}
}
}











}

}
}
}
@@ -173,8 +173,8 @@
<Label Name="labelSpeed" HorizontalAlignment="Center"></Label>
<Label Name="labelDownloaded" HorizontalAlignment="Center" ></Label>
<Label Name="labelPerc" HorizontalAlignment="Center"></Label>
<ProgressBar Name="progressBar" Width="40" Height="12"></ProgressBar>
<Button Name="DownloadStream" BorderBrush="Transparent" Background="Transparent" Content="GET" Click="DownloadStream_Click" Visibility="Visible" />
<ProgressBar Name="progressBar" Width="40" Height="12" Visibility="Hidden"></ProgressBar>
<Button Name="DownloadStream" BorderBrush="Transparent" Background="Transparent" Content="GET" Click="DownloadStream_Click" Visibility="Hidden" />
</StackPanel>
</DockPanel>

0 comments on commit dbeeab3

Please sign in to comment.
You can’t perform that action at this time.