Ejemplo n.º 1
0
 public static void PlayChannel(this BassHandle handle, bool restart = false)
 {
     if (!handle.BASS_ChannelPlay(restart))
     {
         throw new BassException("ChannelPlay failed");
     }
 }
Ejemplo n.º 2
0
 public static void SetChannelAttribute(this BassHandle handle, ChannelAttribute attribute, float value)
 {
     if (!handle.BASS_ChannelSetAttribute(attribute, value))
     {
         throw new BassException("ChannelSetAttribute failed");
     }
 }
Ejemplo n.º 3
0
 public static void StopChannel(this BassHandle handle)
 {
     if (!handle.BASS_ChannelStop())
     {
         throw new BassException("ChannelStop failed");
     }
 }
Ejemplo n.º 4
0
 public static void PauseChannel(this BassHandle handle)
 {
     if (!handle.BASS_ChannelPause())
     {
         throw new BassException("ChannelPause failed");
     }
 }
Ejemplo n.º 5
0
 public static void FreeStream(this BassHandle handle)
 {
     if (!handle.BASS_StreamFree())
     {
         throw new BassException("StreamFree failed");
     }
 }
Ejemplo n.º 6
0
        public static float GetChannelAttribute(this BassHandle handle, ChannelAttribute attribute)
        {
            if (!handle.BASS_ChannelGetAttribute(attribute, out var value))
            {
                throw new BassException("ChannelGetAttribute failed");
            }

            return(value);
        }
Ejemplo n.º 7
0
 private static extern ChannelStatus BASS_ChannelIsActive(this BassHandle handle);
Ejemplo n.º 8
0
 private static extern bool BASS_ChannelStop(this BassHandle handle);
Ejemplo n.º 9
0
 private static extern bool BASS_ChannelPause(this BassHandle handle);
Ejemplo n.º 10
0
 private static extern bool BASS_ChannelPlay(this BassHandle handle, bool restart = false);
Ejemplo n.º 11
0
 private static extern bool BASS_StreamFree(this BassHandle handle);
Ejemplo n.º 12
0
 private static extern double BASS_ChannelBytes2Seconds(this BassHandle handle, ulong position);
Ejemplo n.º 13
0
 public static ulong GetChannelPosition(this BassHandle handle, LengthMode mode)
 {
     return(handle.BASS_ChannelGetPosition(mode));
 }
Ejemplo n.º 14
0
 public static ulong GetChannelLength(this BassHandle handle, LengthMode mode)
 {
     return(handle.BASS_ChannelGetLength(mode));
 }
Ejemplo n.º 15
0
 private static extern ulong BASS_ChannelGetPosition(this BassHandle handle, LengthMode mode);
Ejemplo n.º 16
0
 private static extern bool BASS_ChannelSetAttribute(this BassHandle handle, ChannelAttribute attribute, float value);
Ejemplo n.º 17
0
 public static ChannelStatus GetChannelStatus(this BassHandle handle)
 {
     return(handle.BASS_ChannelIsActive());
 }
Ejemplo n.º 18
0
        public static unsafe void Initialize(int device = -1, uint frequency = 44000, IntPtr windowHandle = default)
        {
            lock (LoadLock)
            {
                Log.Information($"Loading Bass version {BASS_GetVersion()}");

#if WINDOWS
                const string filter = "*." + Arch + ".dll";
#elif LINUX
                const string filter = "*." + Arch + ".so";
#elif OSX
                const string filter = "*." + Arch + ".dylib";
#endif

                foreach (var file in Directory.EnumerateFiles("BassPlugins", filter, SearchOption.AllDirectories))
                {
                    var path   = Path.GetFullPath(file);
                    var handle = BASS_PluginLoad(path, PluginUnicodeFlag);
                    if (handle == 0)
                    {
                        throw new BassException($"Loading {path} as plugin failed");
                    }
                    var infoPtr = BASS_PluginGetInfo(handle);
                    if (infoPtr == null)
                    {
                        throw new BassException($"Getting plugin info for {path} failed");
                    }
                    var info = *infoPtr;
                    Log.Information($"Loaded Bass plugin {Path.GetFileNameWithoutExtension(path)} version {info.version}. Supported formats: {string.Join(", ", ListSupportedFormats(info))}");
                }

#if WINDOWS
                if (windowHandle == IntPtr.Zero)
                {
                    windowHandle = GetActiveWindow();
                }
#endif

                if (!BASS_Init(device, frequency, 0, windowHandle, IntPtr.Zero))
                {
                    throw new BassException("Init failed");
                }

                if (BASS_GetConfig(BassConfig.Float) == 0)
                {
                    _floatFlag = StreamFlags.None;
                }
                else
                {
                    BassHandle floatable = BASS_StreamCreate(44100, 1, StreamFlags.SampleFloat, IntPtr.Zero, IntPtr.Zero); // try creating a floating-point stream
                    if (floatable != BassHandle.Null)
                    {
                        BASS_StreamFree(floatable); // floating-point channels are supported (free the test stream)
                        _floatFlag = StreamFlags.SampleFloat;
                    }
                    else
                    {
                        _floatFlag = StreamFlags.None;
                    }
                }

                if (_floatFlag.HasFlag(StreamFlags.SampleFloat))
                {
                    Log.Information("Enabling floating point data output");
                }


                Log.Information($"Setting useragent to {WebHelper.UserAgent}");
                BASS_SetConfigPtr(BassConfig.NetAgent, WebHelper.UserAgent);

                Log.Information("Bass initialization complete");
            }
        }
Ejemplo n.º 19
0
 public static double ConvertBytesToSeconds(this BassHandle handle, ulong position)
 {
     return(handle.BASS_ChannelBytes2Seconds(position));
 }