Exemplo n.º 1
0
        public void LoadFile(string soundPath)
        {
            if (string.IsNullOrEmpty(soundPath) || !File.Exists(soundPath))
            {
                FreeStream();
                return;
            }

            // Free Stream
            FreeStream();

            // File Stream
            var fileMemory = File.ReadAllBytes(soundPath);

            // _handle = Bass.CreateStream(soundfile, 0, 0, BassFlags.Default | BassFlags.Float | BassFlags.AutoFree);

            // _handle = Bass.CreateStream(soundfile);

            _handle = Bass.CreateStream(fileMemory, 0, fileMemory.Length, BassFlags.Default);

            // Free
            try
            {
                fileMemory = null;
                File.Delete(soundPath);
                GC.Collect();
            }
            catch { }

            if (_handle == 0)
            {
                Console.WriteLine("Player: Error Creating stream for {0} {1:G}", soundPath, Bass.LastError);
                return;
            }

            _Length = Bass.ChannelBytes2Seconds(_handle, Bass.ChannelGetLength(_handle));

            // Bass.FloatingPointDSP = true;

            if (Bass.ChannelSetDevice(_handle, 1))
            {
                Console.WriteLine("Player: Error Set Device {0:G}", Bass.LastError);
                return;
            }

            // Set Volume
            Volume = _VolumeTrack.Value / 100.0;

            // Set Balance
            Balance = _PanTrack.Value / 100.0f;

            // Play
            Play(true);
        }
Exemplo n.º 2
0
        public static byte[] GetMusicOrder(ITagsProvider ITA)
        {
            int n = (int)Bass.ChannelGetLength(ITA.Handle, PositionFlags.MusicOrders);

            byte[] b = new byte[n];

            IntPtr ptr = Bass.ChannelGetTags(ITA.Handle, TagType.MusicOrders);

            Marshal.Copy(ptr, b, 0, n);

            return(b);
        }