Exemplo n.º 1
0
 protected virtual void _Dispose(bool disposing)
 {
     if (!disposing)
     {
         CLog.Debug("Audio stream " + _Medium + " was not closed.");
     }
 }
Exemplo n.º 2
0
        static void BuildManifestInternel(DLCItem dlcItem)
        {
            var    builds       = AssetBundleBuildsCache = BuildBuildRules(dlcItem);
            string dlcName      = dlcItem.Name;
            string manifestPath = DLCAssetMgr.GetDLCManifestPath(dlcName);
            string dlcItemPath  = DLCAssetMgr.GetDLCItemPath(dlcName);

            List <string> bundles = new List <string>();
            List <string> assets  = new List <string>();

            if (builds.Count > 0)
            {
                foreach (var item in builds)
                {
                    bundles.Add(item.assetBundleName);
                    foreach (var assetPath in item.assetNames)
                    {
                        assets.Add(assetPath + ":" + (bundles.Count - 1));
                    }
                }
            }

            #region 创建Manifest文件
            if (File.Exists(manifestPath))
            {
                File.Delete(manifestPath);
            }
            DLCManifest dlcManifest = new DLCManifest();
            foreach (var item in builds)
            {
                BundleData tempData = new BundleData();
                tempData.DLCName    = dlcItem.Name;
                tempData.BundleName = item.assetBundleName;
                foreach (var asset in item.assetNames)
                {
                    AssetPathData pathData = new AssetPathData();
                    pathData.FullPath = asset;
                    pathData.FileName = Path.GetFileNameWithoutExtension(asset);
                    if (AllAssets.ContainsKey(asset))
                    {
                        pathData.SourceBundleName = AllAssets[asset];
                    }
                    tempData.AssetFullPaths.Add(pathData);
                }
                dlcManifest.Data.Add(tempData);
            }
            BaseFileUtils.SaveJson(manifestPath, dlcManifest, true);
            #endregion

            #region dlcitem
            if (File.Exists(dlcItemPath))
            {
                File.Delete(dlcItemPath);
            }
            BaseFileUtils.SaveJson(dlcItemPath, dlcItem, true);
            #endregion

            CLog.Debug("[BuildScript] BuildManifest with " + assets.Count + " assets and " + bundles.Count + " bundels.");
        }
Exemplo n.º 3
0
 public override CTextureRef GetTexture(string name)
 {
     if (_Parent.Name == "Default" && !_Required.Textures.Contains(name))
     {
         CLog.Debug("Non-Default color: " + name);
     }
     return(base.GetTexture(name) ?? _BaseSkin.GetTexture(name));
 }
Exemplo n.º 4
0
 public override CVideoStream GetVideo(string name, bool loop)
 {
     if (_Parent.Name == "Default" && !_Required.Videos.Contains(name))
     {
         CLog.Debug("Non-Default color: " + name);
     }
     return(base.GetVideo(name, loop) ?? _BaseSkin.GetVideo(name, loop));
 }
Exemplo n.º 5
0
 public override bool GetColor(string name, out SColorF color)
 {
     if (_Parent.Name == "Default" && !_Required.Colors.Contains(name))
     {
         CLog.Debug("Non-Default color: " + name);
     }
     return(base.GetColor(name, out color) || _BaseSkin.GetColor(name, out color));
 }
Exemplo n.º 6
0
 public override bool Load()
 {
     _BaseSkin = CThemes.CurrentThemes[-1].CurrentSkin;
     if (!base.Load())
     {
         return(false);
     }
     for (int i = 1; i <= CSettings.MaxScreenPlayer; i++)
     {
         if (!_Data.Colors.ContainsKey("Player" + i))
         {
             continue;
         }
         CLog.Debug("Party themes cannot contain player colors. They will be ignored!");
         break;
     }
     return(true);
 }
Exemplo n.º 7
0
        private void _InitNext(string lastTest)
        {
            string msg = "Errors " + lastTest + ": ";

            for (int i = 0; i < _CurPassedCount.Length; i++)
            {
                msg               += _CurTestCount - _CurPassedCount[i] + " ";
                _PassedCount[i]   += _CurPassedCount[i];
                _CurPassedCount[i] = 0;
            }
            msg += "of " + _CurTestCount;
            CLog.Debug(msg);
            _TestCount   += _CurTestCount;
            _CurTestCount = 0;
            //Do a reset first as we actually have an impossible situation (drop by multiple octaves)
            byte[] data = new byte[4096 * 2];
            _Process(data);
        }
Exemplo n.º 8
0
 private void _Dispose(bool disposing)
 {
     if (_Disposed)
     {
         return;
     }
     if (!disposing)
     {
         CLog.Debug("Did not close CPortAudioHandle");
     }
     //Make sure we do not leek any streams as we may keep PA open
     if (_Streams.Count > 0)
     {
         CLog.Debug("Did not close " + _Streams.Count + "PortAudio-Stream(s)");
         while (_Streams.Count > 0)
         {
             CloseStream(_Streams[0]);
         }
     }
     lock (_Mutex)
     {
         if (_Disposed)
         {
             return;
         }
         Debug.Assert(_RefCount > 0);
         _RefCount--;
         if (_RefCount == 0)
         {
             try
             {
                 PortAudio.Pa_Terminate();
             }
             catch (Exception ex)
             {
                 CLog.Error(ex, "Error disposing PortAudio");
             }
         }
         _Disposed = true;
     }
 }
Exemplo n.º 9
0
        public void RunTest(bool reRun = false)
        {
            if (_IsRun && !reRun)
            {
                return;
            }
            _IsRun = true;

            _InitTests();

            _TestSines();
            _InitNext("Sines");

            _TestFile("toneG3.wav", 19);
            _InitNext("Real G3");

            _TestFile("toneG3Miss.wav", 19);
            _InitNext("Real G3 with miss. fundamental");

            _TestFile("toneG4.wav", 31);
            _InitNext("Real G4");

            _TestFile("whistling3.wav", "whistling3.txt");
            _InitNext("High whistling");

            _TestFile("sClausVoc.wav", "sClausVoc.txt");
            _InitNext("Real song");

            _TestSpeed();
            CLog.Debug("Finished: ");
            for (int i = 0; i < _Analyzers.Count; i++)
            {
                string msg = _Analyzers[i].GetType().Name + ":";
                msg += " Errors=" + (_TestCount - _PassedCount[i]);
                msg += " Passed=" + _PassedCount[i];
                msg += " Total=" + _TestCount;
                msg += " Speed=" + _SamplesPerSec[i] / 1000 + "kSamples/s (=" + (_SamplesPerSec[i] / 44100) + "rec.s/s)";
                CLog.Debug(msg);
            }
        }
Exemplo n.º 10
0
        private void _TestFile(string fileName, IList <STimedNote> tones)
        {
            CWavFile wavFile = new CWavFile();

            try
            {
                if (!wavFile.Open(fileName))
                {
                    return;
                }
                if (wavFile.BitsPerSample != 16)
                {
                    wavFile.Close();
                    return;
                }
                int       samplesRead        = 0;
                int       curTimeIndex       = -1;
                int       curNote            = -1;
                const int maxSamplesPerBatch = 512;
                bool[]    valids             = new bool[_Tones.Length];
                while (wavFile.NumSamplesLeft > maxSamplesPerBatch)
                {
                    byte[] samples = wavFile.GetNextSamples16BitAsBytes(maxSamplesPerBatch, 1);
                    samplesRead += samples.Length / 2;
                    int time = samplesRead * 1000 / wavFile.SampleRate;
                    _Process(samples);
                    while (curTimeIndex + 1 < tones.Count && time >= tones[curTimeIndex + 1].Time)
                    {
                        curTimeIndex++;
                        curNote = tones[curTimeIndex].Note;
                    }
                    if (curNote < 0)
                    {
                        continue;
                    }
                    _CurTestCount++;
                    bool error = false;
                    for (int i = 0; i < _Tones.Length; i++)
                    {
                        valids[i] = _IsNoteValid(_Tones[i], time, tones);
                        if (valids[i])
                        {
                            _CurPassedCount[i]++;
                        }
                        else
                        {
                            error = true;
                        }
                    }
                    if (error)
                    {
                        string msg = "Note " + _ToneToNote(curNote) + " at " + time + "ms detected as ";
                        for (int i = 0; i < _Tones.Length; i++)
                        {
                            msg += _ToneToNote(_Tones[i]) + (valids[i] ? "" : "(!)") + "; ";
                        }
                        CLog.Debug(msg);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error on file " + fileName + ": " + e);
            }
            wavFile.Close();
        }
Exemplo n.º 11
0
        private void _TestSines()
        {
            const int toneFrom = 0;
            const int toneTo   = 47; //B5
            const int sampleCt = 4096;
            const int batchCt  = 512;

            byte[] data2 = new byte[batchCt * 2];
            Console.WriteLine("Testing notes " + _ToneToNote(toneFrom) + " - " + _ToneToNote(toneTo));
            double angle = 0;

            bool[] valids = new bool[_Analyzers.Count];
            for (int distort = 0; distort < 10; distort++)
            {
                //Do a reset first as we actually have an impossible situation (drop by multiple octaves)
                byte[] data = new byte[sampleCt * 2];
                _Process(data);
                for (int tone = toneFrom; tone <= toneTo; tone++)
                {
                    _GetSineWave(_BaseToneFreq * Math.Pow(_HalftoneBase, tone), 44100, sampleCt, ref angle, out data);
                    if (tone == 46 && distort == 4)
                    {
                        data = new byte[data.Length];
                    }
                    _Distort(data, tone, distort);

                    for (int i = 0; i < sampleCt / batchCt; i++)
                    {
                        Buffer.BlockCopy(data, i * batchCt * 2, data2, 0, batchCt * 2);
                        _Process(data2);
                        if (i * batchCt < 2048)
                        {
                            continue;
                        }
                        _CurTestCount++;
                        bool ok = true;
                        for (int j = 0; j < valids.Length; j++)
                        {
                            valids[j] = _Tones[j] == tone;
                            if (!valids[j])
                            {
                                ok = false;
                            }
                            else
                            {
                                _CurPassedCount[j]++;
                            }
                        }
                        if (ok)
                        {
                            continue;
                        }
                        string msg = "Note " + _ToneToNote(tone) + "(" + distort + ") at buffer " + (i + 1) + "/" + (sampleCt / batchCt) + " detected as ";
                        for (int j = 0; j < valids.Length; j++)
                        {
                            msg += _ToneToNote(_Tones[j]) + (valids[j] ? "" : "(!)") + "; ";
                        }
                        CLog.Debug(msg);

                        /*CWavFile w = new CWavFile();
                         * w.Create(tone + "-" + distort + ".wav", 1, 44100, 16);
                         * w.Write16BitSamples(data);
                         * w.Close();*/
                    }
                }
            }
        }