Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
Windows 7 support
Browse files Browse the repository at this point in the history
  • Loading branch information
weespin committed Mar 22, 2021
1 parent d382488 commit d561efc
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 20 deletions.
63 changes: 45 additions & 18 deletions AcapellaDownloader/Form1.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading;
Expand Down Expand Up @@ -33,12 +34,24 @@ private void btnDownload_Click(object sender, EventArgs e)
var s = dialog.ShowDialog();
if (s == DialogResult.OK)
{
using (var mf = new MediaFoundationReader(soundLink))
{
PitchProvider = new SmbPitchShiftingSampleProvider(mf.ToSampleProvider().ToMono());
PitchProvider.PitchFactor = Pitch;
MediaFoundationEncoder.EncodeToMp3(PitchProvider.ToWaveProvider(), dialog.FileName, 48000);
MessageBox.Show(downloaded);
if (!Program.bOldWindows)
{
using (var mf = new MediaFoundationReader(soundLink))
{
PitchProvider = new SmbPitchShiftingSampleProvider(mf.ToSampleProvider().ToMono());
PitchProvider.PitchFactor = Pitch;
MediaFoundationEncoder.EncodeToMp3(PitchProvider.ToWaveProvider(), dialog.FileName, 48000);
MessageBox.Show(downloaded);
}
}
else
{
using (var wc = new WebClient())
{
wc.DownloadFile(soundLink, dialog.FileName);
MessageBox.Show(downloaded);

}
}
}
}
Expand Down Expand Up @@ -100,20 +113,34 @@ private void btnPlay_Click(object sender, EventArgs e)
}
void PlaySound(string link, int WaveOutDeviceId)
{
using (var mf = new MediaFoundationReader(link))
using (var wo = new WaveOutEvent())
using (Stream ms = new MemoryStream())
{
wo.DeviceNumber = WaveOutDeviceId;
PitchProvider = new SmbPitchShiftingSampleProvider(mf.ToSampleProvider().ToMono());
PitchProvider.PitchFactor = Pitch;
wo.Init(PitchProvider);
wo.Volume = VoiceVolume;
wo.Play();
while (wo.PlaybackState == PlaybackState.Playing)
using (Stream stream = WebRequest.Create(link).GetResponse().GetResponseStream())
{
byte[] buffer = new byte[4096];
int read;
while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
{
ms.Write(buffer, 0, read);
}
}

ms.Position = 0;
using (WaveStream mf = new BlockAlignReductionStream(WaveFormatConversionStream.CreatePcmStream(new Mp3FileReader(ms))))
using (var wo = new WaveOutEvent())
{
PitchProvider.PitchFactor = Pitch;
wo.Volume = VoiceVolume;
Thread.Sleep(500);
wo.DeviceNumber = WaveOutDeviceId;
PitchProvider = new SmbPitchShiftingSampleProvider(mf.ToSampleProvider().ToMono());
PitchProvider.PitchFactor = Pitch;
wo.Init(PitchProvider);
wo.Volume = VoiceVolume;
wo.Play();
while (wo.PlaybackState == PlaybackState.Playing)
{
PitchProvider.PitchFactor = Pitch;
wo.Volume = VoiceVolume;
Thread.Sleep(500);
}
}
}
}
Expand Down
9 changes: 8 additions & 1 deletion AcapellaDownloader/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ namespace AcapellaDownloader
{
static class Program
{
public static bool bOldWindows = false;
[STAThread]
static void Main()
{
string[] commandLineArgs = Environment.GetCommandLineArgs();
var OsVersion = Environment.OSVersion.Version;
if (OsVersion.Major <= 6 && OsVersion.Minor <= 1)
{
bOldWindows = true;
}

string[] commandLineArgs = Environment.GetCommandLineArgs();
if (commandLineArgs.Length > 1)
{
CLI.PassCLI(commandLineArgs);
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ Use --voice-list argument to get all voice id's
#### Example:
AcapellaDownloader.exe -t Test string 1 2 3 -v enu_willhappy_22k_ns.bvcu -o test.mp3
## Requirements
Windows 8 or Windows 10
Windows 7 (without changing pitch on download), Windows 8 or Windows 10

0 comments on commit d561efc

Please sign in to comment.