public override void EncodeHeadless(TBase[] objs, PacketData data) { foreach (var obj in objs) { BaseEncoder.Encode(obj, data); } }
private void buttonStop_Click(object sender, System.EventArgs e) { if (plm != null) { plm.Notification -= new EventHandler(plm_Notification); plm.Stop(); plm = null; } this.progressBarLeft.Value = 0; this.progressBarRight.Value = 0; if (enc != null) { enc.Stop(); // finish encoding enc.Dispose(); enc = null; } if (asio != null) { asio.RemoveMirror(); } asio.Stop(); this.buttonStart.Enabled = true; }
public static void ConvertToOgg(string sourcePath, string destPath) { const string EXTENTION = ".ogg"; UnityEngine.Debug.Assert(destPath.EndsWith(EXTENTION)); if (sourcePath.EndsWith(EXTENTION)) { // Re-encoding is slow as hell, speed this up System.IO.File.Copy(sourcePath, destPath); } else { string inputFile = sourcePath; string outputFile = destPath; EncoderOGG encoder = new EncoderOGG(0); encoder.EncoderDirectory = encoderDirectory; if (!BaseEncoder.EncodeFile(inputFile, outputFile, encoder, null, true, false)) { UnityEngine.Debug.LogErrorFormat("Unable to encode ogg file from {0} to {1}. Error {2}", sourcePath, destPath, Bass.BASS_ErrorGetCode().ToString()); } } }
public static void Encode(string file) { if (File.Exists(file)) { var encoderLAME = new EncoderLAME(0) { LAME_Bitrate = (int)EncoderLAME.BITRATE.kbps_192, LAME_Mode = EncoderLAME.LAMEMode.Default, LAME_Quality = EncoderLAME.LAMEQuality.Quality }; var resp = BaseEncoder.EncodeFile( inputFile: file, outputFile: file + "_small.mp3", encoder: encoderLAME, proc: null, overwriteOutput: true, deleteInput: false, updateTags: false, fromPos: 5.0f, toPos: 10.0f ); var e = Bass.BASS_ErrorGetCode(); Console.WriteLine(resp); Console.WriteLine(e); } }
public string Digest(string message) { Initialize(); AssertUtils.AssertNotNull(message); return(BaseEncoder.Encode(Digester.Digest(Charset.GetBytes(message)))); }
public Encoder(MainForm mainForm, OutputFileController outputFiles) { string inputFile = mainForm.sourceFilePathTextBox.Text; for (int i = 0; i < outputFiles.CountOfSoundFiles; i++) { outputFiles.GoToIndex(i); var tag = outputFiles.TagInfo; if (string.IsNullOrEmpty(tag.track)) { tag.track = (i + 1).ToString(); } var resp = BaseEncoder.EncodeFile( inputFile: inputFile, outputFile: mainForm.destinationFilePathTextBox.Text + outputFiles.GetFileName() + ".mp3", encoder: new EncoderLAME(0) { LAME_UseVBR = true, TAGs = tag }, proc: new BaseEncoder.ENCODEFILEPROC(mainForm.FileEncodingNotification), overwriteOutput: true, deleteInput: false, updateTags: false, fromPos: outputFiles.GetStartTime() + 0.0f, toPos: outputFiles.GetEndTime() + 0.0f ); mainForm.ColorDataGrid(i); } }
public string Decrypt(string message) { Initialize(); AssertUtils.AssertNotNull(message); return(Charset.GetString(Encryptor.Decrypt(BaseEncoder.Decode(message)))); }
public bool Verify(string message, string digested) { Initialize(); AssertUtils.AssertNotNull(message); AssertUtils.AssertNotNull(digested); return(Digester.Verify(Charset.GetBytes(message), BaseEncoder.Decode(digested))); }
/// <summary> /// Saves an audio file as a wave. /// </summary> /// <param name="inFilename">The input filename.</param> /// <param name="outFilename">The output filename.</param> public static void SaveAsWave(string inFilename, string outFilename) { var encoder = new EncoderWAV(0) { WAV_BitsPerSample = 16 }; BaseEncoder.EncodeFile(inFilename, outFilename, encoder, null, true, false); }
public override TBase[] DecodeHeadless(PacketData data, int arrayLength) { var result = new TBase[arrayLength]; for (int i = 0; i < arrayLength; i++) { result[i] = BaseEncoder.Decode(data); } return(result); }
public override void Encode(TType obj, PacketData data) { var isNull = EqualityComparer <TType> .Default.Equals(obj, default(TType)); Types.Bool.Encode(isNull, data); if (!isNull) { BaseEncoder.Encode(obj, data); } }
public new string Digest(string password) { Initialize(); AssertUtils.AssertNotNull(password); byte[] salt = new byte[SaltSize]; random.GetBytes(salt); byte[] secKey = secretKeyGenerator.Generate(password, salt, IterationCount, KeySize); return(BaseEncoder.Encode(ArrayUtils.Append(salt, secKey))); }
public override int Estimate(TBase[] objs) { int bytes = 0; foreach (var obj in objs) { if (!EqualityComparer <TBase> .Default.Equals(obj, default(TBase))) { bytes += BaseEncoder.Estimate(obj); } } return(bytes + BoolArrayEncoder.getBytesLength(objs.Length) + 4); }
public override int Estimate(TBase[] objs) { if (BaseEncoder.FixedSize) { return(objs.Length * BaseEncoder.ByteSize + 4); } int result = 4; foreach (var obj in objs) { result += BaseEncoder.Estimate(obj); } return(result); }
public new bool Verify(string password, string digested) { Initialize(); AssertUtils.AssertNotNull(password); AssertUtils.AssertNotNull(digested); byte[] dg = BaseEncoder.Decode(digested); AssertUtils.AssertTrue(dg.Length > SaltSize); byte[] salt = new byte[SaltSize]; byte[] secKey = new byte[dg.Length - SaltSize]; ArrayUtils.Copy(dg, salt, secKey); byte[] computedSecKey = secretKeyGenerator.Generate(password, salt, IterationCount, KeySize); return(computedSecKey.SequenceEqual(secKey)); }
public static void ConvertToOgg(string sourcePath, string destPath) { const string EXTENTION = ".ogg"; UnityEngine.Debug.Assert(destPath.EndsWith(EXTENTION)); if (sourcePath.EndsWith(EXTENTION)) { // Re-encoding is slow as hell, speed this up System.IO.File.Copy(sourcePath, destPath, true); } else { string inputFile = sourcePath; string outputFile = destPath; #if (UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN) string encoderDirectory = UnityEngine.Application.streamingAssetsPath; UnityEngine.Debug.Assert(File.Exists(Path.Combine(encoderDirectory, "oggenc2.exe"))); EncoderOGG encoder = new EncoderOGG(0); encoder.EncoderDirectory = encoderDirectory; encoder.OGG_Quality = encoder.Kbps2Quality(c_oggEncodingQualityKbps); // Should equate to about quality level 8 out of a max of 10 if (!BaseEncoder.EncodeFile(inputFile, outputFile, encoder, null, true, false)) { UnityEngine.Debug.LogErrorFormat("Unable to encode ogg file from {0} to {1}. Error {2}", sourcePath, destPath, Bass.BASS_ErrorGetCode().ToString()); } #elif (UNITY_STANDALONE_LINUX || UNITY_EDITOR_LINUX) if (!new FFmpegTranscoding().main(sourcePath, destPath)) { UnityEngine.Debug.LogErrorFormat("Unable to encode ogg file from {0} to {1}", sourcePath, destPath); } #else UnityEngine.Debug.LogErrorFormat("Unable to encode ogg file from {0} to {1}. Platform not implemented.", sourcePath, destPath); #endif } }
/// <summary> /// Starts encoding using the given Parameters /// </summary> /// <param name = "stream"></param> /// <param name = "encoderParms"></param> public BASSError StartEncoding(int stream) { BaseEncoder encoder = SetEncoderSettings(stream); encoder.EncoderDirectory = _pathToEncoders; encoder.OutputFile = _outFile; encoder.InputFile = null; // Use stdin bool encoderHandle = encoder.Start(null, IntPtr.Zero, false); if (!encoderHandle) { return(Bass.BASS_ErrorGetCode()); } long pos = 0; long chanLength = Bass.BASS_ChannelGetLength(stream); _isAborted = false; byte[] encBuffer = new byte[60000]; // our encoding buffer while (Bass.BASS_ChannelIsActive(stream) == BASSActive.BASS_ACTIVE_PLAYING && !_isAborted) { // getting sample data will automatically feed the encoder int len = Bass.BASS_ChannelGetData(stream, encBuffer, encBuffer.Length); pos = Bass.BASS_ChannelGetPosition(stream); double percentComplete = pos / (double)chanLength * 100.0; // Send the message msg.MessageData["progress"] = percentComplete; queue.Send(msg); } encoder.Stop(); return(BASSError.BASS_OK); }
public override TBase[] DecodeHeadless(PacketData data, int arrayLength) { var result = new TBase[arrayLength]; BoolArrayEncoder.DecodeBoolArray(data, arrayLength, index => result[index] = BaseEncoder.Decode(data)); return(result); }
private void buttonStart_Click(object sender, System.EventArgs e) { asio = new BassAsioHandler(true, 0, 0, 2, BASSASIOFormat.BASS_ASIO_FORMAT_16BIT, 44100); // set a mirror on output channel 0 (for monitoring) asio.SetMirror(0); this.checkBoxMonitor.Checked = true; // start ASIO (actually starts recording/playing) BASS_ASIO_INFO info = BassAsio.BASS_ASIO_GetInfo(); bool ok = asio.Start(info.bufmax); if (!ok) { MessageBox.Show("Could not start ASIO : " + BassAsio.BASS_ASIO_ErrorGetCode().ToString()); } // now setup the encoder on the provided asio bass channel (which will be created by the above SetFullDuplex call) if (radioButtonLAME.Checked) { lame = new EncoderLAME(asio.InputChannel); lame.InputFile = null; //STDIN lame.OutputFile = "test.mp3"; lame.LAME_Bitrate = (int)EncoderLAME.BITRATE.kbps_128; lame.LAME_Mode = EncoderLAME.LAMEMode.Default; lame.LAME_Quality = EncoderLAME.LAMEQuality.Quality; lame.Start(null, IntPtr.Zero, false); enc = lame; } else if (radioButtonOGG.Checked) { ogg = new EncoderOGG(asio.InputChannel); ogg.InputFile = null; //STDIN ogg.OutputFile = "test.ogg"; ogg.OGG_UseQualityMode = true; ogg.OGG_Quality = 4.0f; ogg.Start(null, IntPtr.Zero, false); enc = ogg; } else if (radioButtonAAC.Checked) { aac = new EncoderNeroAAC(asio.InputChannel); aac.InputFile = null; //STDIN aac.OutputFile = "test.mp4"; aac.NERO_Bitrate = 64; aac.Start(null, IntPtr.Zero, false); enc = aac; } else if (radioButtonWAVE.Checked) { // writing 16-bit wave file here (even if we use a float asio channel) wav = new EncoderWAV(asio.InputChannel); wav.InputFile = null; // STDIN wav.OutputFile = "test.wav"; wav.Start(null, IntPtr.Zero, false); enc = wav; } this.buttonStart.Enabled = false; // display the level plm = new DSP_PeakLevelMeter(asio.InputChannel, 0); plm.UpdateTime = 0.1f; // 100ms plm.Notification += new EventHandler(plm_Notification); }
public void TestToBase32(string unconverted, string converted) { Assert.Equal(converted, BaseEncoder.FromBase64(unconverted)); }
private BaseEncoder SetEncoderSettings(int stream) { BaseEncoder encoder = null; switch (_encoder) { case "mp3": EncoderLAME encLame = new EncoderLAME(stream); if (Options.MainSettings.RipLameExpert.Length > 0) { encLame.LAME_CustomOptions = Options.MainSettings.RipLameExpert; encLame.LAME_UseCustomOptionsOnly = true; } else { if (Options.MainSettings.RipLamePreset == (int)Options.LamePreset.ABR) { encLame.LAME_PresetName = Options.MainSettings.RipLameABRBitRate.ToString(); } else { encLame.LAME_PresetName = Enum.GetName(typeof(Options.LamePreset), Options.MainSettings.RipLamePreset).ToLower(); } } encoder = encLame; break; case "ogg": EncoderOGG encOgg = new EncoderOGG(stream); if (Options.MainSettings.RipOggExpert.Length > 0) { encOgg.OGG_CustomOptions = Options.MainSettings.RipOggExpert; encOgg.OGG_UseCustomOptionsOnly = true; } else { encOgg.OGG_Quality = Convert.ToInt32(Options.MainSettings.RipOggQuality); } encoder = encOgg; break; case "flac": EncoderFLAC encFlac = new EncoderFLAC(stream); if (Options.MainSettings.RipFlacExpert.Length > 0) { encFlac.FLAC_CustomOptions = Options.MainSettings.RipFlacExpert; encFlac.FLAC_UseCustomOptionsOnly = true; } else { encFlac.FLAC_CompressionLevel = Options.MainSettings.RipFlacQuality; } // put a 1k padding block for Tagging in front encFlac.FLAC_Padding = 1024; encoder = encFlac; break; case "m4a": EncoderFAAC encAAC = new EncoderFAAC(stream); int bitrate = Convert.ToInt32(Options.MainSettings.RipEncoderAACBitRate.Substring(0, Options.MainSettings. RipEncoderAACBitRate.IndexOf(' '))); encAAC.FAAC_Bitrate = bitrate; encAAC.FAAC_Quality = 100; encAAC.FAAC_UseQualityMode = true; encAAC.FAAC_WrapMP4 = true; encoder = encAAC; break; case "wav": EncoderWAV encWav = new EncoderWAV(stream); encoder = encWav; break; case "wma": EncoderWMA encWma = new EncoderWMA(stream); string[] sampleFormat = Options.MainSettings.RipEncoderWMASample.Split(','); string encoderFormat = Options.MainSettings.RipEncoderWMA; if (encoderFormat == "wmapro" || encoderFormat == "wmalossless") { encWma.WMA_UsePro = true; } else { encWma.WMA_ForceStandard = true; } if (Options.MainSettings.RipEncoderWMACbrVbr == "Vbr") { encWma.WMA_UseVBR = true; encWma.WMA_VBRQuality = Convert.ToInt32(Options.MainSettings.RipEncoderWMABitRate); } else { encWma.WMA_Bitrate = Convert.ToInt32(Options.MainSettings.RipEncoderWMABitRate) / 1000; } if (sampleFormat[0] == "24") { encWma.WMA_Use24Bit = true; } encoder = encWma; break; case "mpc": EncoderMPC encMpc = new EncoderMPC(stream); if (Options.MainSettings.RipEncoderMPCExpert.Length > 0) { encMpc.MPC_CustomOptions = Options.MainSettings.RipEncoderMPCExpert; encMpc.MPC_UseCustomOptionsOnly = true; } else { encMpc.MPC_Preset = (EncoderMPC.MPCPreset)Enum.Parse(typeof(EncoderMPC.MPCPreset), Options.MainSettings.RipEncoderMPCPreset); } encoder = encMpc; break; case "wv": EncoderWavPack encWv = new EncoderWavPack(stream); if (Options.MainSettings.RipEncoderWVExpert.Length > 0) { encWv.WV_CustomOptions = Options.MainSettings.RipEncoderWVExpert; encWv.WV_UseCustomOptionsOnly = true; } else { if (Options.MainSettings.RipEncoderWVPreset == "-f") { encWv.WV_FastMode = true; } else { encWv.WV_HighQuality = true; } } encoder = encWv; break; } return(encoder); }
public override TType Decode(PacketData data) { var isNull = Types.Bool.Decode(data); return(isNull ? default(TType) : BaseEncoder.Decode(data)); }
public override void EncodeHeadless(TBase[] objs, PacketData data) { BoolArrayEncoder.EncodeBoolArray(objs, data, index => BaseEncoder.Encode(objs[index], data)); }