Пример #1
0
        internal static bool IsTranscodeRequired(string ext)
        {
            Plugin.FileCodec codec = GetFileCodec(ext);

            return(Plugin.settings.transcode.useMusicBeeSettings ||
                   Plugin.settings.transcode.enableDSP ||
                   Plugin.settings.transcode.replayGainMode != Plugin.ReplayGainMode.Off ||
                   Plugin.settings.transcode.formats.Contains(codec));
        }
Пример #2
0
        private void applyButton_Click(object sender, EventArgs e)
        {
            List <Plugin.FileCodec> formats = new List <Plugin.FileCodec> {
                Plugin.FileCodec.Unknown
            };

            foreach (var item in transcodeFormats.CheckedItems)
            {
                Plugin.FileCodec codec = AudioStream.GetFileCodec(transcodeFormats.GetItemText(item));
                Debug.Assert(codec != Plugin.FileCodec.Unknown);
                formats.Add(codec);
            }

            ushort validPort;

            if (ushort.TryParse(portInput.Text, out validPort))
            {
                if (port != validPort && port > 1)
                {
                    validPort = Plugin.settings.serverPort;
                }
            }

            Settings settings = new Settings
            {
                serverName = serverNameInput.Text,
                serverPort = validPort,
                transcode  = new AudioStream.TranscodeOptions
                {
                    usePCM = pcm.Checked,
                    useMusicBeeSettings = mbAudio.Checked,
                    enableDSP           = dsp.Checked,
                    replayGainMode      = replayGainTrack.Checked ? Plugin.ReplayGainMode.Track
                                   : replayGainAlbum.Checked ? Plugin.ReplayGainMode.Album
                                   : replayGainSmart.Checked ? Plugin.ReplayGainMode.Smart
                                   : Plugin.ReplayGainMode.Off,
                    formats = formats
                },
                optimisedUserAgent = null,
                optimisedMetadata  = null,
                optimisationPinned = pinOptimisation.Checked
            };

            Save(settings);
        }
Пример #3
0
        private void SetFormSettingsInternal(Settings settings)
        {
            serverNameInput.Text = settings.serverName;
            portInput.Text       = settings.serverPort.ToString();

            pinOptimisation.Checked = settings.optimisationPinned;
            pinOptimisation.Enabled = settings.optimisedMetadata != null;
            optimiseLabel.Text      = Plugin.TrimToCharacter(optimiseLabel.Text, ':') + ": " + (settings.optimisedUserAgent ?? "None");

            pcm.Checked     = settings.transcode.usePCM;
            mbAudio.Checked = settings.transcode.useMusicBeeSettings;
            dsp.Checked     = settings.transcode.enableDSP;

            switch (settings.transcode.replayGainMode)
            {
            case Plugin.ReplayGainMode.Album:
                replayGainAlbum.Checked = true;
                break;

            case Plugin.ReplayGainMode.Track:
                replayGainTrack.Checked = true;
                break;

            case Plugin.ReplayGainMode.Smart:
                replayGainSmart.Checked = true;
                break;

            default:
                replayGainOff.Checked = true;
                break;
            }

            for (int i = 0; i < transcodeFormats.Items.Count; i++)
            {
                var item = transcodeFormats.Items[i];
                Plugin.FileCodec codec = AudioStream.GetFileCodec(transcodeFormats.GetItemText(item));
                Debug.Assert(codec != Plugin.FileCodec.Unknown);
                if (settings.transcode.formats.Contains(codec))
                {
                    transcodeFormats.SetItemChecked(i, true);
                }
            }
        }
Пример #4
0
        internal static Plugin.FileCodec GetFileCodec(string ext)
        {
            Plugin.FileCodec result = Plugin.FileCodec.Unknown;

            switch (ext.ToLower())
            {
            case "mp3": {
                result = Plugin.FileCodec.Mp3;
            } break;

            case "m4a":
            case "m4b":
            case "m4p":
            case "m4r":
            case "3gp":
            case "mp4":
            case "aac": {
                // alac might sometimes be reported as aac
                // but anything that supports aac should support alac, too
                result = Plugin.FileCodec.Aac;
            } break;

            case "flac": {
                result = Plugin.FileCodec.Flac;
            } break;

            case "ogv":
            case "oga":
            case "ogx":
            case "ogm":
            case "ogg": {
                result = Plugin.FileCodec.Ogg;
            } break;

            case "wv":
            case "wavpack": {
                result = Plugin.FileCodec.WavPack;
            } break;

            case "wma": {
                result = Plugin.FileCodec.Wma;
            } break;

            case "tak": {
                result = Plugin.FileCodec.Tak;
            } break;

            case "mpc":
            case "mpp":
            case "mp+": {
                result = Plugin.FileCodec.Mpc;
            } break;

            case "wav":
            case "wave": {
                result = Plugin.FileCodec.Wave;
            } break;

            case "asx": {
                result = Plugin.FileCodec.Asx;
            } break;

            case "alac": {
                result = Plugin.FileCodec.Alac;
            } break;

            case "aif":
            case "aifc":
            case "aiff": {
                result = Plugin.FileCodec.Aiff;
            } break;

            case "l16":
            case "au":
            case "pcm": {
                result = Plugin.FileCodec.Pcm;
            } break;

            case "opus": {
                result = Plugin.FileCodec.Opus;
            } break;

            case "spx": {
                result = Plugin.FileCodec.Spx;
            } break;

            case "dsd": {
                result = Plugin.FileCodec.Dsd;
            } break;
            }

            return(result);
        }