public void ReadMonoFromFileTest() { using (BassAudioService bass = new BassAudioService()) { string tempFile = Path.GetTempPath() + "\\" + 0 + ".wav"; bass.RecodeTheFile(PathToMp3, tempFile, 5512); float[] samples = bass.ReadMonoFromFile(PathToMp3, SampleRate); FileInfo info = new FileInfo(tempFile); long expectedSize = info.Length - WaveHeader; long actualSize = samples.Length * (BitsPerSample / 8); Assert.AreEqual(expectedSize, actualSize); } }
private void BtnResampleClick(object sender, EventArgs e) { if (string.IsNullOrEmpty(_tbPathToFile.Text)) { MessageBox.Show( Resources.SelectAPathToBeDrawn, Resources.SelectFile, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!File.Exists(Path.GetFullPath(_tbPathToFile.Text))) { MessageBox.Show( Resources.NoSuchFile, Resources.NoSuchFile, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } SaveFileDialog sfd = new SaveFileDialog { Filter = Resources.FileFilterWav, FileName = Path.GetFileNameWithoutExtension(_tbPathToFile.Text) + ".wav" }; if (sfd.ShowDialog() == DialogResult.OK) { Action action = () => { using (BassAudioService bass = new BassAudioService()) { string pathToRecoded = Path.GetFullPath(sfd.FileName); bass.RecodeTheFile(_tbPathToFile.Text, pathToRecoded, (int)_nudSampleRate.Value); } }; FadeControls(false); action.BeginInvoke( (result) => { action.EndInvoke(result); FadeControls(true); MessageBox.Show( Resources.FileConverted, Resources.FileConverted, MessageBoxButtons.OK, MessageBoxIcon.Information); }, null); } }
public void CheckFingerprintCreationAlgorithmTest() { using (BassAudioService bassAudioService = new BassAudioService()) { string tempFile = Path.GetTempPath() + 0 + ".wav"; bassAudioService.RecodeTheFile(PathToMp3, tempFile, 5512); long fileSize = new FileInfo(tempFile).Length; List<bool[]> list = workUnitBuilder.BuildWorkUnit().On(PathToMp3).With(fingerprintingConfiguration). GetFingerprintsUsingService(fingerprintingServiceWithBass).Result; // One fingerprint corresponds to a granularity of 8192 samples which is 16384 bytes long expected = fileSize / (fingerprintingConfiguration.SamplesPerFingerprint * 4); Assert.AreEqual(expected, list.Count); File.Delete(tempFile); } }