Ejemplo n.º 1
0
    public override void _Ready()
    {
        IOpl imfOpl = new WoodyEmulatorOpl(OplType.Opl2);

        AddChild(ImfOplPlayer = new OplPlayer()
        {
            Opl         = imfOpl,
            MusicPlayer = new ImfPlayer()
            {
                Opl = imfOpl,
            },
        });

        IOpl idAdlOpl = new WoodyEmulatorOpl(OplType.Opl2);

        AddChild(IdAdlOplPlayer = new OplPlayer()
        {
            Opl         = idAdlOpl,
            MusicPlayer = new IdAdlPlayer()
            {
                Opl = idAdlOpl,
            },
        });

        string imfFile = "SEARCHN_MUS.imf";

        if (!System.IO.File.Exists(imfFile))
        {
            throw new FileNotFoundException();
        }
        else
        {
            using (FileStream imfStream = new FileStream(imfFile, FileMode.Open))
                ((ImfPlayer)ImfOplPlayer.MusicPlayer).Imf = Imf.ReadImf(imfStream);
        }

        string idAdlFile = "GETAMMOSND.adl";

        if (!System.IO.File.Exists(idAdlFile))
        {
            throw new FileNotFoundException();
        }
        else
        {
            using (FileStream idAdlStream = new FileStream(idAdlFile, FileMode.Open))
                Adl = new Adl(idAdlStream);
        }
    }
Ejemplo n.º 2
0
 public void SetSaturationOnDisplay(int vibranceLevel, string displayName)
 {
     SetSaturation((adlDisplayInfo, adlAdapterInfo, adapterIndex) =>
     {
         int infoValue = adlDisplayInfo.DisplayID.DisplayLogicalIndex;
         bool adapterIsAssociatedWithDisplay = adapterIndex == adlDisplayInfo.DisplayID.DisplayLogicalAdapterIndex;
         if (adapterIsAssociatedWithDisplay && (adlAdapterInfo.DisplayName == displayName || displayName == null))
         {
             Adl.AdlDisplayColorSet(
                 adapterIndex,
                 infoValue,
                 Adl.AdlDisplayColorSaturation,
                 vibranceLevel);
         }
     });
 }
Ejemplo n.º 3
0
        public bool IsAvailable()
        {
            if (Adl.AdlMainControlCreate != null)
            {
                if (Adl.AdlSuccess == Adl.AdlMainControlCreate(Adl.AdlMainMemoryAlloc, 1))
                {
                    if (Adl.AdlMainControlDestroy != null)
                    {
                        Adl.AdlMainControlDestroy();
                    }

                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 4
0
            public void Dispose()
            {
                foreach (var intPtr in DisplayBufferList)
                {
                    if (intPtr != IntPtr.Zero)
                    {
                        Marshal.FreeCoTaskMem(intPtr);
                    }
                }

                if (AdapterBuffer != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(AdapterBuffer);
                }

                if (Adl.AdlMainControlDestroy != null)
                {
                    Adl.AdlMainControlDestroy();
                }
            }
Ejemplo n.º 5
0
    public override void _Ready()
    {
        // Adding handler - to show log messages (ILoggerHandler)
        Logger.LoggerHandlerManager
        .AddHandler(new ConsoleLoggerHandler())
        .AddHandler(new FileLoggerHandler())
        .AddHandler(new DebugConsoleLoggerHandler());

        using (FileStream file = new FileStream("WONDERIN_MUS.imf", FileMode.Open))
            Song = ReadImf(file);

        OplPlayer = new OplPlayer(Opl);
        AddChild(OplPlayer);
        AddChild(OplPlayer.AudioStreamPlayer);

        ImfPlayer = new ImfPlayer(Opl)
        {
            Song = Song,
        };
        AddChild(ImfPlayer);

        using (FileStream file = new FileStream(
                   "GETAMMOSND.adl"
                   //"GETMACHINESND.adl"
                   , FileMode.Open))
            Adl = new Adl(file);

        AdlPlayer = new AdlPlayer(Opl);
        AddChild(AdlPlayer);

        Button button = new PlayButton
        {
            Text = "Sound"
        };

        AddChild(button);

        SongStep songStep = new SongStep();

        AddChild(songStep);
    }
Ejemplo n.º 6
0
        public Farm(Dictionary <string, DeviceDescriptor> devices,
                    FarmOptions options,
                    MinerCUOptions cuOptions,
                    MinerCLOptions clOptions,
                    MinerCPOptions cpOptions)
        {
            F          = this;
            _devices   = devices;
            _options   = options;
            _cuOptions = cuOptions;
            _clOptions = clOptions;
            _cpOptions = cpOptions;
            Console.WriteLine("Farm::Farm() begin");

            // Init HWMON if needed
            if (_options.HwMon != 0)
            {
                _telemetry.Hwmon = true;

                // Scan devices to identify which hw monitors to initialize
                var needAdl  = false;
                var needNvml = false;
                foreach (var it in _devices.Values)
                {
                    if (it.SubscriptionType == DeviceSubscriptionType.Cuda)
                    {
                        needNvml = true;
                        continue;
                    }
                    if (it.SubscriptionType == DeviceSubscriptionType.OpenCL)
                    {
                        if (it.CLPlatformType == PlatformCLType.Nvidia)
                        {
                            needNvml = true;
                            continue;
                        }
                        if (it.CLPlatformType == PlatformCLType.Amd)
                        {
                            needAdl = true;
                            continue;
                        }
                    }
                }

                // Adl
                if (needAdl)
                {
                    _adl = new Adl();
                }
                if (_adl != null)
                {
                    // Build Pci identification as done in miners.
                    for (var i = 0; i < _adl.GpuCount; i++)
                    {
                        _mapAdlHandle[_adl.GetPciId(i)] = i;
                    }
                }

                // Nvml
                if (needNvml)
                {
                    _nvml = new Nvml();
                }
                if (_nvml != null)
                {
                    // Build Pci identification as done in miners.
                    for (var i = 0; i < _nvml.GpuCount; i++)
                    {
                        _mapNvmlHandle[_nvml.GetPciId(i)] = i;
                    }
                }
            }

            // Initialize nonce_scrambler
            Shuffle();

            // Start data collector timer
            // It should work for the whole lifetime of Farm regardless it's mining state
            _collectTimer = new Timer(CollectData, null, TimeSpan.Zero, TimeSpan.FromMilliseconds(_collectInterval));

            Console.WriteLine("Farm::Farm() end");
        }
Ejemplo n.º 7
0
        public void Init()
        {
            displays = new List <Display>();
            disposer = new Disposer();

            int numberOfAdapters = 0;

            Adl.AdlMainControlCreate(Adl.AdlMainMemoryAlloc, 1);

            if (Adl.AdlAdapterNumberOfAdaptersGet != null)
            {
                Adl.AdlAdapterNumberOfAdaptersGet(ref numberOfAdapters);
            }

            Adl.AdlMainControlCreate(Adl.AdlMainMemoryAlloc, 1);

            if (numberOfAdapters > 0)
            {
                AdlAdapterInfoArray osAdapterInfoData = new AdlAdapterInfoArray();

                if (Adl.AdlAdapterAdapterInfoGet != null)
                {
                    int    size          = Marshal.SizeOf(osAdapterInfoData);
                    IntPtr adapterBuffer = Marshal.AllocCoTaskMem(size);
                    Marshal.StructureToPtr(osAdapterInfoData, adapterBuffer, false);

                    int adlRet = Adl.AdlAdapterAdapterInfoGet(adapterBuffer, size);
                    if (adlRet == Adl.AdlSuccess)
                    {
                        osAdapterInfoData = (AdlAdapterInfoArray)Marshal.PtrToStructure(adapterBuffer, osAdapterInfoData.GetType());
                        int isActive = 0;

                        for (int i = 0; i < numberOfAdapters; i++)
                        {
                            AdlAdapterInfo adlAdapterInfo = osAdapterInfoData.ADLAdapterInfo[i];

                            int adapterIndex = adlAdapterInfo.AdapterIndex;

                            if (Adl.AdlAdapterActiveGet != null)
                            {
                                adlRet = Adl.AdlAdapterActiveGet(adlAdapterInfo.AdapterIndex, ref isActive);
                            }

                            if (Adl.AdlSuccess == adlRet)
                            {
                                AdlDisplayInfo oneDisplayInfo = new AdlDisplayInfo();

                                if (Adl.AdlDisplayDisplayInfoGet != null)
                                {
                                    IntPtr displayBuffer = IntPtr.Zero;

                                    int numberOfDisplays = 0;
                                    adlRet = Adl.AdlDisplayDisplayInfoGet(adlAdapterInfo.AdapterIndex, ref numberOfDisplays, out displayBuffer, 1);
                                    if (Adl.AdlSuccess == adlRet)
                                    {
                                        List <AdlDisplayInfo> displayInfoData = new List <AdlDisplayInfo>();
                                        for (int j = 0; j < numberOfDisplays; j++)
                                        {
                                            oneDisplayInfo = (AdlDisplayInfo)Marshal.PtrToStructure(new IntPtr(displayBuffer.ToInt64() + j * Marshal.SizeOf(oneDisplayInfo)), oneDisplayInfo.GetType());
                                            displayInfoData.Add(oneDisplayInfo);
                                        }

                                        for (int j = 0; j < numberOfDisplays; j++)
                                        {
                                            AdlDisplayInfo adlDisplayInfo = displayInfoData[j];

                                            if (adlDisplayInfo.DisplayID.DisplayLogicalAdapterIndex == -1)
                                            {
                                                continue;
                                            }

                                            displays.Add(new Display
                                            {
                                                DisplayInfo = adlDisplayInfo,
                                                AdapterInfo = adlAdapterInfo,
                                                Index       = adapterIndex,
                                            });
                                        }
                                    }

                                    disposer.DisplayBufferList.Add(displayBuffer);
                                }
                            }
                        }
                    }

                    disposer.AdapterBuffer = adapterBuffer;
                }
            }
        }