Пример #1
0
        public void Link(string fullPath, FreeMountContext context)
        {
            if (ChannelList.Count > 1)
            {
                Console.WriteLine("[WARN] Audio with multiple channels is not supported. Send me the sample for research.");
            }

            var ext = Path.GetExtension(fullPath).ToLowerInvariant();

            switch (ext)
            {
            case ".at9":
                var at9Arch = (Atrac9ArchData)ChannelList[0];
                at9Arch.Data.Data = File.ReadAllBytes(fullPath);
                break;

            case ".xwma":
                var xwmaArch = (XwmaArchData)ChannelList[0];
                xwmaArch.ReadFromXwma(File.OpenRead(fullPath));
                break;

            case ".wav":
            case ".ogg":
                var newArch = context.WaveToArchData(ChannelList[0].Extension, File.ReadAllBytes(fullPath),
                                                     ChannelList[0].WaveExtension);
                if (newArch != null)
                {
                    ChannelList[0].SetPsbArchData(newArch.ToPsbArchData());
                }
                else
                {
                    if (ChannelList[0].Extension == ext)
                    {
                        LoadFromRawFile(ChannelList[0], fullPath);
                    }
                    else
                    {
                        Console.WriteLine(
                            $"[WARN] There is no encoder for {ChannelList[0].Extension}! {fullPath} is not used.");
                    }
                }

                break;

            case ".bin":
            case ".raw":
            default:
                LoadFromRawFile(ChannelList[0], fullPath);
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// Load a common audio file into a channel
        /// </summary>
        /// <param name="channel">target channel</param>
        /// <param name="fullPath">path to load audio file</param>
        /// <param name="fileName">used in some audio types to keep file name</param>
        /// <param name="fileExt">common audio extension like "wav"</param>
        /// <param name="encodeExt">encode audio extension like "vag"</param>
        /// <param name="context"></param>
        private void LoadFileToChannel(IArchData channel, string fullPath, string fileName, string fileExt, string encodeExt, FreeMountContext context)
        {
            var newArch = context.WaveToArchData(this, encodeExt, File.ReadAllBytes(fullPath), fileName,
                                                 channel.WaveExtension);

            if (newArch != null)
            {
                channel.SetPsbArchData(newArch.ToPsbArchData());
            }
            else
            {
                if (channel.Extension == fileExt)
                {
                    LoadFromRawFile(channel, fullPath);
                }
                else
                {
                    Console.WriteLine(
                        $"[WARN] There is no encoder for {channel.Extension}! {fullPath} is not used.");
                }
            }
        }