当前位置: 首页>>代码示例>>C#>>正文


C# FileReader.getChannels方法代码示例

本文整理汇总了C#中FileReader.getChannels方法的典型用法代码示例。如果您正苦于以下问题:C# FileReader.getChannels方法的具体用法?C# FileReader.getChannels怎么用?C# FileReader.getChannels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileReader的用法示例。


在下文中一共展示了FileReader.getChannels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: initMusic

    /// <summary>
    /// Initializes the static class.
    /// Loads the music, analyzes the music, stores useful information about it.
    /// THIS FUNCTION WILL ANALYZE MUSIC UNLESS IT FINDS A CACHE FILE!
    /// (analysis takes ages!)
    /// </summary>
    /// <param name='pathToMusicFile'>
    /// Path to music file.
    /// </param>
    public static IEnumerator initMusic(string pathToMusicFile)
    {
        // Set flags
        songLoaded = false;
        tagDataSet = false;
        abortSoundProcessing = false;
        isWritingCacheFile = false;
        loadingProgress = 0;

        #if UNITY_WEBPLAYER
        // For the WebPlayer: Just get everything from WebPlayerRytData.cs
        peaks = WebPlayerRytData.getPeaks(Game.Song);
        loudPartTimeStamps = WebPlayerRytData.getLoudFlags(Game.Song);
        variationFactor = WebPlayerRytData.getVariationFactor(Game.Song);
        songLoaded = true;
        currentlyLoadedSong = "xXBACKgroundMUSICXx";
        yield break;
        #else

        // For Tutorial: Just get everything from TutorialRytData.cs
        if(Game.GameMode == Game.Mode.Tutorial) {
            peaks = TutorialRytData.getPeaks();
            loudPartTimeStamps = TutorialRytData.getLoudFlags();
            variationFactor = TutorialRytData.getVariationFactor();
            audioLength = 213.883f;
            frequency = 44100;
            channels = 2;
            songLoaded = true;
            currentlyLoadedSong = "xXBACKgroundMUSICXx";
            tagDataSet = true;
            yield break;
        }

        // Initialize file handle
        float start = Time.realtimeSinceStartup;
        if(freader!=null) {
            freader.close();
            freader = null;
        }
        freader = new FileReader (pathToMusicFile);
        FileReader.ReadStatus success = freader.read (); // Doesn't really "read" (unless it's a WAV file)
        while (freader.isReading()) {
            yield return null;
        }

        // Succeeded reading? (Which means it found the file when we're just streaming)
        if (success != FileReader.ReadStatus.SUCCESS)
        {
            yield break;
        }

        // Set useful information, like AudioClip,length,etc..
        frequency = freader.getFrequency ();
        channels = freader.getChannels ();
        audioLength = freader.getAudioLengthInSecs ();
        currentlyLoadedSong = pathToMusicFile;
        artist = freader.getArtist();
        title = freader.getTitle();

        tagDataSet = true;

        start = Time.realtimeSinceStartup;

        // Check if we have a cache file of the analyzed data for the current song
        string cacheFile = FileWriter.convertToCacheFileName (pathToMusicFile);
        System.IO.FileInfo cachedRytData = new System.IO.FileInfo (cacheFile);

        if (cachedRytData.Exists) {
            // We have a cache file, so we just read the peaks etc from there.
            FileReader rytFile = new FileReader (cacheFile);
            success = rytFile.read ();
            while (rytFile.isReading()) {
                yield return 0;
            }
            if (success != FileReader.ReadStatus.SUCCESS)
            {
                yield break;
            }

            peaks = rytFile.getPeaks ();
            loudPartTimeStamps = rytFile.getLoudnessData ();
            variationFactor = rytFile.getVariationFactor();
            rytFile.close ();
            rytFile = null;

        } else {
            // We have no cache file, so do the actual analysis!
            soundProcessingThread = new System.Threading.Thread(() => SoundProcessor.analyse(freader));
            soundProcessingThread.Start();

            while(SoundProcessor.isAnalyzing) {
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的FileReader.getChannels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。