Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ jobs:
If you are still working on this pull request, please leave a comment indicating that you would like it to remain open.
Thank you for your contributions.
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
stale-pr-label: 'no-pr-activity'
exempt-issue-labels: 'in-progress', 'backlog-feature'
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<RepositoryType>Github</RepositoryType>
<PackageIcon>logo.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Expand Down
Binary file not shown.
Binary file not shown.
Binary file added Samples/SoundFlow.Samples.EditingMixer/Adam.wav
Binary file not shown.
Binary file added Samples/SoundFlow.Samples.EditingMixer/Bella.wav
Binary file not shown.
389 changes: 389 additions & 0 deletions Samples/SoundFlow.Samples.EditingMixer/PersistenceExamples.cs

Large diffs are not rendered by default.

104 changes: 104 additions & 0 deletions Samples/SoundFlow.Samples.EditingMixer/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using SoundFlow.Providers;

namespace SoundFlow.Samples.EditingMixer;

public static class DemoAudio
{
private const int BaseSampleRate = 44100;
private const int BaseChannels = 2;

private static RawDataProvider GenerateTone(TimeSpan duration, float frequency, float amplitude = 0.5f)
{
var totalSamples = (int)(duration.TotalSeconds * BaseSampleRate * BaseChannels);
var samples = new float[totalSamples];
float phase = 0;
var phaseIncrement = (2 * MathF.PI * frequency) / BaseSampleRate;

for (var i = 0; i < totalSamples; i += BaseChannels)
{
var value = MathF.Sin(phase) * amplitude;
for (var ch = 0; ch < BaseChannels; ch++)
{
samples[i + ch] = value;
}
phase += phaseIncrement;
if (phase >= 2 * MathF.PI) phase -= 2 * MathF.PI;
}
return new RawDataProvider(samples);
}

public static RawDataProvider GenerateShortBeep(TimeSpan duration = default)
{
if (duration == default) duration = TimeSpan.FromMilliseconds(500);
return GenerateTone(duration, 880); // A5 tone
}

public static RawDataProvider GenerateLongTone(TimeSpan duration = default)
{
if (duration == default) duration = TimeSpan.FromSeconds(6);
return GenerateTone(duration, 440); // A4 tone
}

public static RawDataProvider GenerateSpeechFragment(TimeSpan duration = default)
{
if (duration == default) duration = TimeSpan.FromSeconds(5);
return GenerateTone(duration, 220, 0.4f); // Simulating speech with A3
}

public static RawDataProvider GenerateMusicLoop(TimeSpan duration = default)
{
if (duration == default) duration = TimeSpan.FromSeconds(2);
return GenerateTone(duration, 660, 0.6f); // E5 tone
}

public static RawDataProvider GenerateFxSound(TimeSpan duration = default)
{
if (duration == default) duration = TimeSpan.FromSeconds(1);
return GenerateTone(duration, 1320, 0.7f); // E6 tone
}

public static TimeSpan Ts(string timestamp)
{
var parts = timestamp.Split([':', '-'], StringSplitOptions.RemoveEmptyEntries);
return new TimeSpan(0, 0, int.Parse(parts[0]), int.Parse(parts[1]), int.Parse(parts[2]));
}
}


public static class Program
{
private static void Main()
{
Console.WriteLine("SoundFlow Editing Module Examples");
Console.WriteLine("=================================");

var running = true;
while (running)
{
Console.WriteLine("\nChoose an examples set to run:");
Console.WriteLine(" 1. Speech Dialogue Between Adam & Bella");
Console.WriteLine(" 2. Basic Tone Based Composition");
Console.WriteLine(" 3. Project Persistence (Save & Load)");
Console.WriteLine(" 0. Exit");
Console.Write("Enter your choice: ");

if (int.TryParse(Console.ReadLine(), out var choice))
{
switch (choice)
{
case 1: SpeechBasedExamples.Run(); break;
case 2: ToneBasedExamples.Run(); break;
case 3: PersistenceExamples.Run(); break;
case 0: running = false; break;
default: Console.WriteLine("Invalid choice. Please try again."); break;
}
}
else
{
Console.WriteLine("Invalid input. Please enter a number.");
}
}

Console.WriteLine("Exited.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Src\SoundFlow.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="Adam.wav">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Bella.wav">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Loading