private void buttonRemoveEnvelope_Click(object sender, EventArgs e) { BassMix.BASS_Mixer_ChannelSetEnvelope(_currentTrack.Channel, BASSMIXEnvelope.BASS_MIXER_ENV_VOL, null); _WF.ClearAllVolumePoints(); _WF.DrawVolume = WaveForm.VOLUMEDRAWTYPE.None; DrawWave(); }
private void buttonSetEnvelope_Click(object sender, EventArgs e) { if (_currentTrack.Channel != 0) { BASS_MIXER_NODE[] nodes = { new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 10d), 1f), new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 13d), 0f), new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 17d), 0f), new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(_mixer, 20d), 1f) }; BassMix.BASS_Mixer_ChannelSetEnvelope(_currentTrack.Channel, BASSMIXEnvelope.BASS_MIXER_ENV_VOL, nodes); // already align the envelope position to the current playback position // pause mixer Bass.BASS_ChannelLock(_mixer, true); long pos = BassMix.BASS_Mixer_ChannelGetPosition(_currentTrack.Channel); // convert source pos to mixer pos long envPos = Bass.BASS_ChannelSeconds2Bytes(_mixer, Bass.BASS_ChannelBytes2Seconds(_currentTrack.Channel, pos)); BassMix.BASS_Mixer_ChannelSetEnvelopePos(_currentTrack.Channel, BASSMIXEnvelope.BASS_MIXER_ENV_VOL, envPos); // resume mixer Bass.BASS_ChannelLock(_mixer, false); // and show it in our waveform _WF.DrawVolume = WaveForm.VOLUMEDRAWTYPE.Solid; foreach (BASS_MIXER_NODE node in nodes) { _WF.AddVolumePoint(node.pos, node.val); } DrawWave(); } }
public static void AdjustSampleVolume(int handle, int mixer, float value) { BASS_MIXER_NODE[] nodes = { new BASS_MIXER_NODE(0, value), }; bool isVolGood = BassMix.BASS_Mixer_ChannelSetEnvelope(handle, BASSMIXEnvelope.BASS_MIXER_ENV_VOL, nodes); }
private void setGain(int deck, float gain) { // annoying dsp code to write // each node is like a (value,time) pair BASS_MIXER_NODE[] nodes = { new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(deck, 0d), gain), }; BassMix.BASS_Mixer_ChannelSetEnvelope(deck, BASSMIXEnvelope.BASS_MIXER_ENV_VOL, nodes); }
public bool DownmixMogg(string CON_file, string output, MoggSplitFormat format, string quality, bool doWii = false, double start = 0.0, double length = 0.0, double fadeIn = 0.0, double fadeOut = 0.0, double volume = 0.0, string stems = "allstems") { if (!ExtractDecryptMogg(CON_file, true)) { return(false); } try { if (!InitBass()) { return(false); } var BassStream = Bass.BASS_StreamCreateFile(Tools.GetOggStreamIntPtr(), 0, Tools.PlayingSongOggData.Length, BASSFlag.BASS_STREAM_DECODE); var channel_info = Bass.BASS_ChannelGetInfo(BassStream); var BassMixer = BassMix.BASS_Mixer_StreamCreate(doWii ? 22050 : channel_info.freq, 2, BASSFlag.BASS_MIXER_END | BASSFlag.BASS_STREAM_DECODE); if (doWii) { BassMix.BASS_Mixer_StreamAddChannelEx(BassMixer, BassStream, BASSFlag.BASS_MIXER_MATRIX, 0, Bass.BASS_ChannelSeconds2Bytes(BassMixer, length)); var track_vol = (float)Utils.DBToLevel(Convert.ToDouble(volume), 1.0); Bass.BASS_ChannelSetPosition(BassStream, Bass.BASS_ChannelSeconds2Bytes(BassStream, start)); BASS_MIXER_NODE[] nodes = { new BASS_MIXER_NODE(0, 0), new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(BassMixer, fadeIn), track_vol), new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(BassMixer, length - fadeOut),track_vol), new BASS_MIXER_NODE(Bass.BASS_ChannelSeconds2Bytes(BassMixer, length), 0) }; BassMix.BASS_Mixer_ChannelSetEnvelope(BassStream, BASSMIXEnvelope.BASS_MIXER_ENV_VOL, nodes, nodes.Count()); } else { BassMix.BASS_Mixer_StreamAddChannel(BassMixer, BassStream, BASSFlag.BASS_MIXER_MATRIX); } var matrix = GetChannelMatrix(Parser.Songs[0], channel_info.chans, stems); BassMix.BASS_Mixer_ChannelSetMatrix(BassStream, matrix); var output_file = output; if (string.IsNullOrWhiteSpace(output)) { output_file = Path.GetDirectoryName(CON_file) + "\\" + Parser.Songs[0].InternalName + (format == MoggSplitFormat.WAV ? ".wav" : ".ogg"); } if (format == MoggSplitFormat.OGG) { var cmd = "bin\\oggenc2.exe -q" + quality + " - -o\"" + output_file + "\""; BassEnc.BASS_Encode_Start(BassMixer, cmd, BASSEncode.BASS_ENCODE_FP_24BIT | BASSEncode.BASS_ENCODE_AUTOFREE, null, IntPtr.Zero); } else { BassEnc.BASS_Encode_Start(BassMixer, output_file, BASSEncode.BASS_ENCODE_PCM | BASSEncode.BASS_ENCODE_AUTOFREE, null, IntPtr.Zero); } while (true) { var buffer = new byte[20000]; var c = Bass.BASS_ChannelGetData(BassMixer, buffer, buffer.Length); if (c < 0) { break; } } UnloadLibraries(); Tools.ReleaseStreamHandle(); return(File.Exists(output_file)); } catch (Exception ex) { ErrorLog.Add("Error downmixing mogg file:"); ErrorLog.Add(ex.Message); UnloadLibraries(); Tools.ReleaseStreamHandle(); return(false); } }