1
Answer

Sound comparison in C#

Good day. I just want to ask a question about our thesis. We were suppose to make a program using c# that can detect a snare drum sound from a song being played. I thought of the idea as comparing the frequency of the default snare drum sound with the song. As soon as it detects that it has the same frequency then it will emphasize the part where it is detected. The question is:

1. How am I going to identify the frequency of a sound using Fast Fourier Transform (FFT)?
2. How am I going to compare them?

Every response or comment is much appreciated. THANK YOU!
Answers (1)
0
Roei Bar

Roei Bar

NA 7.8k 0 15y
well about first question you can restrict the size of header columns here is a sample code:

Try with a template without the PART_HeaderGripper.





    <Style x:Key="{x:Type GridViewColumnHeader}" TargetType="{x:Type GridViewColumnHeader}">
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Background" Value="{StaticResource GridViewColumnHeaderBackground}"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="2,0,2,0"/>
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                    <Grid SnapsToDevicePixels="true"
                          Background="{TemplateBinding Background}">
                        <Border x:Name="HighlightBorder"
                                VerticalAlignment="Bottom"
                                Background="{StaticResource GridViewColumnHeaderHighlightBackground}"
                                BorderBrush="{StaticResource GridViewColumnHeaderDarkBackground}"
                                Height="3"
                                BorderThickness="0,0,0,1"/>
                        <Border BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                Padding="{TemplateBinding Padding}"
                                Margin="1,0,1,0">
                            <ContentPresenter x:Name="HeaderContent"
                                              Margin="0,0,0,1"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              RecognizesAccessKey="True"
                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        </Border>
                        <Canvas>
                        <!--
                            <Thumb x:Name="PART_HeaderGripper" Style="{StaticResource GridViewColumnHeaderGripper}"/>
                        -->
                        </Canvas>
                        <Border x:Name="HeaderPressBorder" BorderThickness="1"/>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="HighlightBorder" Property="BorderBrush"
                                    Value="{StaticResource TabItemHotBorderBrush}"/>
                            <Setter TargetName="HighlightBorder" Property="Background"
                                    Value="{StaticResource TabItemHotBorderBackround}"/>
                            <Setter TargetName="HighlightBorder" Property="CornerRadius" Value="0,0,3,3"/>
                            <Setter TargetName="HighlightBorder" Property="BorderThickness" Value="1,0,1,1"/>
                           
<!-- <Setter TargetName="PART_HeaderGripper"
Property="Background" Value="Transparent"/> -->
                            <Setter Property="Background" Value="{StaticResource GridViewColumnHeaderHoverBackground}"/>
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="HighlightBorder" Property="Visibility" Value="Hidden"/>
                            <Setter TargetName="PART_HeaderGripper" Property="Visibility" Value="Hidden"/>
                           
<Setter TargetName="HeaderPressBorder" Property="BorderBrush"
Value="{StaticResource GridViewColumnHeaderPressBorder}"/>
                            <Setter TargetName="HeaderPressBorder" Property="Margin" Value="1,0,0,0"/>
                            <Setter TargetName="HeaderContent" Property="Margin" Value="1,1,0,0"/>
                            <Setter Property="Background" Value="{StaticResource GridViewColumnHeaderPressBackground}"/>
                            <Setter Property="BorderBrush" Value="{StaticResource GridViewColumnHeaderPressBackground}"/>
                        </Trigger>
                        <Trigger Property="Height" Value="Auto">
                            <Setter Property="MinHeight" Value="20"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                           
<Setter Property="Foreground" Value="{DynamicResource {x:Static
SystemColors.GrayTextBrushKey}}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Role" Value="Floating">
                <Setter Property="Opacity" Value="0.7"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                            <Canvas Name="PART_FloatingHeaderCanvas" />
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="Role" Value="Padding">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                            <Grid Background="{TemplateBinding Background}" SnapsToDevicePixels="true">
                                <Border VerticalAlignment="Bottom"
                                        Background="{StaticResource GridViewColumnHeaderHighlightBackground}"
                                        BorderBrush="{StaticResource GridViewColumnHeaderDarkBackground}"
                                        Height="3"
                                        BorderThickness="0,0,0,1"/>
                                <Border BorderThickness="{TemplateBinding BorderThickness}"
                                        BorderBrush="{TemplateBinding BorderBrush}"
                                        Padding="{TemplateBinding Padding}"
                                        Margin="1,0,1,0"/>
                            </Grid>
                            <ControlTemplate.Triggers>
                                <Trigger Property="Height" Value="Auto">
                                    <Setter Property="MinHeight" Value="20"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

i didnt quite understand the second part