private void loadDeckB_Click(object sender, EventArgs e) { if (mix.running()) { string item = getItem(); if (!item.Equals(string.Empty) || item != null) { if (mix.loadDeckB(item)) { WFRight = new WaveForm(item, new Un4seen.Bass.Misc.WAVEFORMPROC(RightCallback), deckAOsc); WFRight.CallbackFrequency = 500; // every 10 seconds rendered WFRight.ColorBackground = Color.Black; WFRight.ColorBeat = Color.Lime; WFRight.ColorVolume = Color.Red; WFRight.RenderStart(true, BASSFlag.BASS_DEFAULT); deckBLabel.Text = item.Split(sep).Last(); timeDeckB.Text = mix.getTimeDeck('B'); mix.computeCrossFade(); } } else { Console.WriteLine("Could not load into Deck A"); } } }
private void buttonPlay_Click(object sender, EventArgs e) { // svuoto sempre lo stream prima di crearne uno nuovo Bass.BASS_StreamFree(streamHandle); Bass.BASS_StreamFree(waveStreamHandle); // controllo che il file di cui creare lo stream esista if (fileName != String.Empty) { // apro il file fileStream = File.OpenRead(fileName); // creo un handle per lo streaming dal file //streamHandle = Bass.BASS_StreamCreateFileUser(BASSStreamSystem.STREAMFILE_NOBUFFER, BASSFlag.BASS_DEFAULT | BASSFlag.BASS_MUSIC_PRESCAN, soundStream, IntPtr.Zero); streamHandle = Bass.BASS_StreamCreateFile(fileName, 0, fileStream.Length, BASSFlag.BASS_DEFAULT); //waveForm = new WaveForm(fileName, new WAVEFORMPROC(WaveChunkLoad), null); waveForm = new WaveForm("prova"); waveForm.FrameResolution = 0.01f; //waveForm.RenderStart(true, BASSFlag.BASS_DEFAULT); waveForm.RenderStart(streamHandle, true, false); waveForm.CallbackFrequency = 5; //waveForm.RenderStartRecording(streamHandle, 5, 5); //myRecProc = new RECORDPROC(MyRecoring); //recHandle = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, myRecProc, ); if (streamHandle != 0 && Bass.BASS_ChannelPlay(streamHandle, false)) { Thread t = new Thread(updateFrames); t.Start(); buttonPause.Enabled = true; buttonStop.Enabled = true; buttonPlay.Enabled = false; buttonOpen.Enabled = false; } else { buttonOpen.Enabled = true; buttonPlay.Enabled = false; buttonPause.Enabled = false; buttonStop.Enabled = false; } } }
private void buttonPlay_Click(object sender, EventArgs e) { wfdrawer = null; try { if (player == null) { player = new Player(MFM.fileName, MFM.fileStream.Length, MFM.fileStream); } //waveForm = new WaveForm(fileName, new WAVEFORMPROC(WaveChunkLoad), null); if (waveForm == null) { waveForm = new WaveForm(); } waveForm.FrameResolution = 0.01f; //waveForm.RenderStart(true, BASSFlag.BASS_DEFAULT); waveForm.RenderStart(player.streamHandle, true, false); // waveForm.CallbackFrequency = 5; //waveForm.RenderStartRecording(streamHandle, 5, 5); //myRecProc = new RECORDPROC(MyRecoring); //recHandle = Bass.BASS_RecordStart(44100, 2, BASSFlag.BASS_RECORD_PAUSE, myRecProc, ); wfdrawer = new WaveformDrawer(waveForm, player.streamHandle, pictureBoxWave); if (player.play()) { wfdrawer.startDrawing(); buttonPause.Enabled = true; buttonStop.Enabled = true; buttonPlay.Enabled = false; buttonOpen.Enabled = false; } else { buttonOpen.Enabled = true; buttonPlay.Enabled = false; buttonPause.Enabled = false; buttonStop.Enabled = false; } } catch (Exception ex) { } }
/// <summary> /// Loads the wave data for the current track /// </summary> private void LoadTrackWaveData() { _waveRendered = false; if (!File.Exists(Filename)) { return; } Wave = new WaveForm(Filename, WaveForm_Callback, this) { FrameResolution = 0.001f, CallbackFrequency = 30000, ColorBackground = Color.Black, ColorLeft = Color.Navy, ColorLeftEnvelope = Color.LightGray, ColorRight = Color.Navy, ColorRightEnvelope = Color.LightGray, ColorMarker = Color.Gold, ColorBeat = Color.LightSkyBlue, ColorVolume = Color.White, DrawEnvelope = false, DrawWaveForm = WaveForm.WAVEFORMDRAWTYPE.Mono, DrawMarker = WaveForm.MARKERDRAWTYPE.Line | WaveForm.MARKERDRAWTYPE.Name | WaveForm.MARKERDRAWTYPE.NameBoxFilled, MarkerLength = 0.9f }; Wave.RenderStart(true, BASSFlag.BASS_DEFAULT); SetMarkers(); while (!_waveRendered) { Application.DoEvents(); Thread.Sleep(100); } }
/// <summary> /// Loads the wave data for the current track /// </summary> private void LoadTrackWaveData() { _waveRendered = false; if (!File.Exists(Filename)) return; Wave = new WaveForm(Filename, WaveForm_Callback, this) { FrameResolution = 0.001f, CallbackFrequency = 30000, ColorBackground = Color.Black, ColorLeft = Color.Navy, ColorLeftEnvelope = Color.LightGray, ColorRight = Color.Navy, ColorRightEnvelope = Color.LightGray, ColorMarker = Color.Gold, ColorBeat = Color.LightSkyBlue, ColorVolume = Color.White, DrawEnvelope = false, DrawWaveForm = WaveForm.WAVEFORMDRAWTYPE.Mono, DrawMarker = WaveForm.MARKERDRAWTYPE.Line | WaveForm.MARKERDRAWTYPE.Name | WaveForm.MARKERDRAWTYPE.NameBoxFilled, MarkerLength = 0.9f }; Wave.RenderStart(true, BASSFlag.BASS_DEFAULT); SetMarkers(); while (!_waveRendered) { Application.DoEvents(); Thread.Sleep(100); } }
public void Load(string file) { if (file == null || !File.Exists(file)) { return; } Bass.BASS_StreamFree(streamID); Bass.BASS_StreamFree(streamFileID); if (lastFile != file) { lastFile = file; WaveModel?.Dispose(); var wf = new WaveForm(file); wf.FrameResolution = 0.005; if (wf.RenderStart(false, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_STREAM_PRESCAN | BASSFlag.BASS_FX_FREESOURCE)) { var samples = new float[wf.Wave.data.Length]; var maxPeak = 0f; for (int i = 0; i < wf.Wave.data.Length; i++) { var sample = wf.Wave.data[i]; var peakLeft = sample.left / (float)short.MaxValue; var peakRight = sample.right / (float)short.MaxValue; var peak = Math.Max(Math.Abs(peakLeft), Math.Abs(peakRight)); maxPeak = Math.Max(peak, maxPeak); samples[i] = peak; } var vertexes = new Queue <float>(); // averaging values for (int i = 0; i < samples.Length; i++) { if (maxPeak > 0.001) { samples[i] /= maxPeak; } samples[i] *= 0.9f; vertexes.Enqueue(i / (float)samples.Length * 100000); vertexes.Enqueue(samples[i]); } WaveModel = ModelManager.LoadModel2ToVao(vertexes.ToArray()); wf.Reset(); } } var stream = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_STREAM_PRESCAN | BASSFlag.BASS_FX_FREESOURCE); var tempo = Tempo; streamFileID = stream; streamID = BassFx.BASS_FX_TempoCreate(streamFileID, BASSFlag.BASS_STREAM_PRESCAN); Tempo = tempo; Bass.BASS_ChannelGetAttribute(streamID, BASSAttribute.BASS_ATTRIB_TEMPO_FREQ, ref originval); Reset(); }