Skip to content

Commit

Permalink
Adding more Driller controls
Browse files Browse the repository at this point in the history
  • Loading branch information
tstavropoulos committed Feb 9, 2019
1 parent 4e32409 commit 3b12a7a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
11 changes: 6 additions & 5 deletions MusicPlayer/AudioUtilities/PhaseVocoderStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public class PhaseVocoderStream : SampleAggregatorBase
private const int EXPANDED_FFT_SIZE = BASE_FFT_SIZE + 1;
private const int OVERLAP_FACTOR = 32;

private const float COMBINE_FACTOR = 1f / OVERLAP_FACTOR;

private int _bufferIndex = 0;
private int _bufferCount = 0;

Expand Down Expand Up @@ -179,7 +181,6 @@ public override int Read(float[] buffer, int offset, int count)
int outputSamples = (int)(_baseFFTSamples / Speed);
int realStep = outputSamples / OVERLAP_FACTOR;

float effectiveSpeed = _baseFFTSamples / (float)outputSamples;
_bufferIndex = 0;
_bufferCount = _channels * realStep;

Expand Down Expand Up @@ -223,7 +224,7 @@ public override int Read(float[] buffer, int offset, int count)
//Accumualte the window samples
for (int i = 0; i < outputSamples; i++)
{
outputAccumulation[_channels * i + channel] += WindowOutput(i, outputSamples) * ifftBuffer[i].Real;
outputAccumulation[_channels * i + channel] += COMBINE_FACTOR * WindowOutput(i, outputSamples) * ifftBuffer[i].Real;
}
}

Expand Down Expand Up @@ -259,15 +260,15 @@ public override int Read(float[] buffer, int offset, int count)

public override long Position
{
get => (long)Math.Ceiling(base.Position / Speed);
get => base.Position;
set
{
ClearBuffers();
base.Position = Math.Min((long)Math.Floor(value * Speed), base.Length);
base.Position = Math.Min(value, base.Length);
}
}

public override long Length => (long)Math.Ceiling(base.Length / Speed);
public override long Length => base.Length;

#endregion SampleAggregatorBase Overrides
#region Helper Methods
Expand Down
10 changes: 8 additions & 2 deletions MusicPlayer/Driller/LooperPlaybackPanel.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,24 @@
<Button ToolTip="Loopback" Grid.Column="1" Grid.Row="3" Margin="0"
Click="OnLoopbackClick"
Content="" Style="{StaticResource PlayerButtons}"/>
<Button ToolTip="Set Stop Marker" Grid.Column="4" Grid.Row="3" Margin="0"
<Button ToolTip="Set Stop Marker" Grid.Column="2" Grid.Row="3" Margin="0"
Click="OnSetStopClick"
Content="" Style="{StaticResource PlayerButtons}"/>

<!-- Row 4 -->
<StackPanel Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="4" Orientation="Horizontal" Margin="5,2,0,2">
<StackPanel Grid.Column="0" Grid.Row="4" Grid.ColumnSpan="2" Orientation="Horizontal" Margin="5,2,0,2">
<TextBlock Text="" VerticalAlignment="Center" Foreground="White"
Style="{StaticResource UIFontStyle}"/>
<Slider Orientation="Horizontal" VerticalAlignment="Center" Width="100"
Minimum="0.5" Maximum="1.0"
LargeChange="0.1" SmallChange="0.02"
Value="{Binding Source={x:Static player:MusicManager.Instance}, Path=Speed, Mode=TwoWay}"/>
</StackPanel>
<Button ToolTip="Walk Region Backwards" Grid.Column="2" Grid.Row="4" Margin="0"
Click="OnWalkBackClick"
Content="" Style="{StaticResource PlayerButtons}"/>
<Button ToolTip="Walk Region Forward" Grid.Column="3" Grid.Row="4" Margin="0"
Click="OnWalkForwardClick"
Content="" Style="{StaticResource PlayerButtons}"/>
</Grid>
</UserControl>
15 changes: 15 additions & 0 deletions MusicPlayer/Driller/LooperPlaybackPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ private void LooperPlaybackPanel_Unloaded(object sender, RoutedEventArgs e)
private void OnSetStartClick(object sender, RoutedEventArgs e) => progressSlider.LowerValue = progressSlider.Value;
private void OnSetStopClick(object sender, RoutedEventArgs e) => progressSlider.UpperValue = progressSlider.Value;

private void OnWalkBackClick(object sender, RoutedEventArgs e)
{
double temp = progressSlider.LowerValue;
progressSlider.LowerValue -= progressSlider.UpperValue - progressSlider.LowerValue;
progressSlider.UpperValue = temp;
}

private void OnWalkForwardClick(object sender, RoutedEventArgs e)
{
double temp = progressSlider.UpperValue;
progressSlider.UpperValue += temp - progressSlider.LowerValue;
progressSlider.LowerValue = temp;
}

private void PlayerStateChanged(PlayerState newState) => State = newState;

private void progressSlider_BoundsChanged(object sender, BoundsChangedEventArgs e)
Expand Down Expand Up @@ -88,5 +102,6 @@ void ILooperUpdater.ResetBounds()
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

#endregion INotifyPropertyChanged

}
}
4 changes: 2 additions & 2 deletions MusicPlayer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.8.12.0")]
[assembly: AssemblyFileVersion("0.8.12.0")]
[assembly: AssemblyVersion("0.8.20.0")]
[assembly: AssemblyFileVersion("0.8.20.0")]
[assembly: Guid("C6D85D0B-5661-41EE-9405-7DFCF7E63798")]

0 comments on commit 3b12a7a

Please sign in to comment.