Ejemplo n.º 1
0
    protected override bool Setup(byte[] data)
    {
        _offset = ReadWavHeaders(data);
        if (_wavContainer.Failed)
        {
            return(false);
        }

        float totalFrames = (_wavContainer.FileLength / _wavContainer.BytesPerFrame);

        _wavContainer.FileLength = (int)totalFrames;

        totalFrames /= 2;

        if (_wavContainer.ChannelCount != 4)
        {
            Debug.LogError("ERROR: Wrong channel count found in file.");
            return(false);
        }

        _wavContainer.ByteRate /= 2; // Adjust for splitting channels
        AudioClip clip12 = AudioClip.Create("Channel12", (int)totalFrames, 2, _wavContainer.SampleRate, true, OnAudioRead12);
        AudioClip clip34 = AudioClip.Create("Channel34", (int)totalFrames, 2, _wavContainer.SampleRate, true, OnAudioRead34);

        _audioInformation = new AudioInformation(clip12, clip34);

        return(true);
    }
Ejemplo n.º 2
0
    private void ApplyClipChanges(AudioInformation info, bool writeChanges)
    {
        Selection.objects = new Object[] { }; // unselect to get "Apply" to work automatically.

        // ReSharper disable once AccessToStaticMemberViaDerivedType
        var importer = (AudioImporter)AudioImporter.GetAtPath(info.FullPath);
        AudioImporterSampleSettings settings = importer.defaultSampleSettings;

        importer.forceToMono       = info.ForceMono;
        importer.loadInBackground  = info.LoadBG;
        importer.preloadAudioData  = info.Preload;
        settings.loadType          = info.LoadType;
        settings.compressionFormat = info.CompressionFormat;
        if (settings.compressionFormat == AudioCompressionFormat.Vorbis)
        {
            settings.quality = info.Quality;
        }
        settings.sampleRateSetting = info.SampleRateSetting;
        if (settings.sampleRateSetting == AudioSampleRateSetting.OverrideSampleRate)
        {
            settings.sampleRateOverride = (uint)info.SampleRateOverride;
        }

        importer.defaultSampleSettings = settings;

        AssetDatabase.ImportAsset(info.FullPath, ImportAssetOptions.ForceUpdate);
        info.HasChanged = true;

        if (writeChanges)
        {
            WriteFile(_clipList);
        }
    }
Ejemplo n.º 3
0
        public void Search()
        {
            var httpGet = new Mock <IHttpGet>();
            var aiExt   = new AudioInformation(PortalApplication.Object, new Http());

            httpGet.Setup(m => m.Get(It.IsAny <string>())).Returns(QueryOctopus());

            var result = aiExt.Search("", "").First();

            Assert.That(result.Id, Is.EqualTo("1"));
            Assert.That(result.Index, Is.EqualTo("1"));
            Assert.That(result.Stimulus.URI, Is.EqualTo("rtpm://TBD_{INSERT_SESSION_GUID}"));
            Assert.That(result.Stimulus.Type, Is.EqualTo("audio/mp3"));
            Assert.That(result.Stimulus.MD5, Is.EqualTo("aa576ff5e76fe76ba587ab57d53"));
            Assert.That(result.Stimulus.Authentication, Is.EqualTo("TODO WHAT IS NEEDED"));
            Assert.That(result.Stimulus.StartOffset, Is.EqualTo("00:00:30.23254353"));
            Assert.That(result.Stimulus.EndOffset, Is.EqualTo("00:00:31.2325435"));
            Assert.That(result.Stimulus.Duration, Is.EqualTo("00:00:01.2325435"));
            Assert.That(result.Metadata.SchemaId, Is.EqualTo("ItemType1"));
            Assert.That(result.Segments.First().CaterogyId, Is.EqualTo("1"));
            Assert.That(result.Segments.First().StartTime, Is.EqualTo("00:21:21.454322"));
            Assert.That(result.Segments.First().EndTime, Is.EqualTo("00:21:25.454222"));
            Assert.That(result.Segments.First().Duration, Is.EqualTo("00:01:25.454222"));
            Assert.That(result.Segments.First().Index, Is.EqualTo("1"));
            Assert.That(result.Segments.First().Editable, Is.EqualTo("true"));
            Assert.That(result.Segments.First().Deletable, Is.EqualTo("true"));
            Assert.That(result.Segments.First().ColorGroup, Is.EqualTo("1"));
            Assert.That(result.Segments.First().Metadata.SchemaId, Is.EqualTo("SegmentType1"));
            Assert.That(result.Segments.First().Metadata.Fields["TranscriptionAsString"].Value, Is.EqualTo("Der er ikke fejet noget ind under gulvtæppet sagde Poul Schluter i dagens..."));
        }
Ejemplo n.º 4
0
 public AudioItem FindItemByVideo(AudioInformation _Audio)
 {
     if (InvokeRequired)
     {
         Invoke(new MethodInvoker(() => FindItemByVideo(_Audio)));
     }
     return(Controls.OfType <AudioItem>().FirstOrDefault(control => control._Audio.Equals(_Audio)));
 }
Ejemplo n.º 5
0
 private static void RevertChanges(AudioInformation info)
 {
     info.CompressionBitrate = info.OrigCompressionBitrate;
     info.ForceMono          = info.OrigForceMono;
     info.Format             = info.OrigFormat;
     info.LoadType           = info.OrigLoadType;
     info.Is3D = info.OrigIs3D;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Meldet, ob Bild, Ton und Videotext neu aufgebaut werden müssen.
        /// </summary>
        /// <param name="info">Vergleichswert.</param>
        /// <returns>Gesetzt, wenn eine relevante Veränderung erkannt wurde.</returns>
        private bool CompareSourceInformation(SourceInformation info)
        {
            // Always changed
            if (null == CurrentSourceConfiguration)
            {
                return(true);
            }

            // Picture
            if (CurrentSourceConfiguration.VideoStream != info.VideoStream)
            {
                return(true);
            }
            if (0 != CurrentSourceConfiguration.VideoStream)
            {
                if (CurrentSourceConfiguration.VideoType != info.VideoType)
                {
                    return(true);
                }
            }

            // Videotext
            if (CurrentSourceConfiguration.TextStream != info.TextStream)
            {
                return(true);
            }

            // Audio count
            if (CurrentSourceConfiguration.AudioTracks.Count != info.AudioTracks.Count)
            {
                return(true);
            }

            // Compare all
            for (int i = CurrentSourceConfiguration.AudioTracks.Count; i-- > 0;)
            {
                // Load
                AudioInformation oldAudio = CurrentSourceConfiguration.AudioTracks[i], newAudio = info.AudioTracks[i];

                // Compare
                if (oldAudio.AudioStream != newAudio.AudioStream)
                {
                    return(true);
                }
                if (oldAudio.AudioType != newAudio.AudioType)
                {
                    return(true);
                }
                if (0 != string.Compare(oldAudio.Language, newAudio.Language, true))
                {
                    return(true);
                }
            }

            // No change
            return(false);
        }
Ejemplo n.º 7
0
        public void DownloadAudioAsync(AudioInformation audioInformation, FileFormat format, AudioBitrate bitrate, string destinationFileName)
        {
            if (!audioInformation.IsAvailableInFormatAndBitrate(format, bitrate))
                throw new QualityNotAvailableException();
            
            audioInProgress = audioInformation;

            var downloadLink = audioInformation.GetDownloadURL(format, bitrate);
            webClient.DownloadFileAsync(new Uri(downloadLink), destinationFileName);
        }
Ejemplo n.º 8
0
    /// <summary>
    /// Load the data from our files.  This is a subscribed function, do not call this function.
    /// </summary>
    public void Load()
    {
        musicSource.volume = DataManager.globalData.MusicVolume;
        sfxSource.volume   = DataManager.globalData.SFXVolume;
        musicID            = DataManager.levelData.MusicID;

        music = MusicArray [musicID] as AudioInformation;

        musicSource.clip = music.clip;
        musicSource.Play();
    }
Ejemplo n.º 9
0
        /// <summary>
        /// Ändert die aktuelle Tonspur.
        /// </summary>
        /// <param name="audio">Name der aktuellen Tonspur gemäß der Senderliste
        /// oder <i>null</i> für die bevorzugte Tonspur.</param>
        /// <returns>Name des aktuellen Senders und der aktuellen Tonspur.</returns>
        public override string SetAudio(string audio)
        {
            // Not possible
            if (null == CurrentSourceConfiguration)
            {
                return((null == CurrentService) ? StationName : CurrentService.Name);
            }

            // Ask favorites for default
            if (string.IsNullOrEmpty(audio))
            {
                audio = Favorites.GetPreferredAudio();
            }

            // Always remember
            m_LastAudio = audio;

            // Remember if not a service
            if (null == CurrentPortal)
            {
                LocalInfo.LocalAudio = audio;
            }

            // Audio to use
            AudioInformation info = null;

            // Try default
            if (!string.IsNullOrEmpty(audio))
            {
                info = CurrentSourceConfiguration.AudioTracks.Find(a => 0 == string.Compare(audio, a.ToString(), true));
            }

            // Start up
            Activate(info);

            // Enable service parser if we are allowed to to so
            if (!Profile.DisableProgramGuide)
            {
                if (!Profile.GetFilter(CurrentSourceConfiguration.Source).DisableProgramGuide)
                {
                    // Stop current
                    if (null != ServiceParser)
                    {
                        ServiceParser.Disable();
                    }

                    // Create new
                    ServiceParser = new ServiceParser(Profile, (null == CurrentPortal) ? CurrentSourceConfiguration.Source : CurrentPortal.Source);
                }
            }

            // Report full name
            return(string.Format("{0} ({1})", (null == CurrentService) ? StationName : CurrentService.Name, (null == info) ? "-" : info.ToString()));
        }
Ejemplo n.º 10
0
 public void RemoveItem(AudioInformation _Audio)
 {
     if (InvokeRequired)
     {
         Invoke(new MethodInvoker(() => RemoveItem(_Audio)));
     }
     foreach (AudioItem control in Controls.OfType <AudioItem>().Where(control => control._Audio.Equals(_Audio)))
     {
         Controls.Remove(control);
     }
 }
Ejemplo n.º 11
0
    private static void RevertChanges(AudioInformation info)
    {
        info.ForceMono = info.OrigForceMono;
        info.LoadBG    = info.OrigLoadBG;
        info.Preload   = info.OrigPreload;

        info.LoadType           = info.OrigLoadType;
        info.Quality            = info.OrigQuality;
        info.CompressionFormat  = info.OrigCompressionFormat;
        info.SampleRateSetting  = info.OrigSampleRateSetting;
        info.SampleRateOverride = info.OrigSampleRateOverride;
    }
Ejemplo n.º 12
0
    private void BuildCache()
    {
        var filePaths = AssetDatabase.GetAllAssetPaths();

        var audioInfo = new AudioInfoData();

        _filterClips = null;
        _pageNumber  = 0;

        var updatedTime = DateTime.Now.Ticks;

        foreach (var aPath in filePaths)
        {
            if (!aPath.EndsWith(".wav", StringComparison.InvariantCultureIgnoreCase) &&
                !aPath.EndsWith(".mp3", StringComparison.InvariantCultureIgnoreCase) &&
                !aPath.EndsWith(".ogg", StringComparison.InvariantCultureIgnoreCase) &&
                !aPath.EndsWith(".aiff", StringComparison.InvariantCultureIgnoreCase))
            {
                continue;
            }

            // ReSharper disable once AccessToStaticMemberViaDerivedType
            var importer = (AudioImporter)AudioImporter.GetAtPath(aPath);

            var bitrate = importer.compressionBitrate;

            if (bitrate < 0)
            {
                bitrate = 156000;
            }

            // ReSharper disable once UseObjectOrCollectionInitializer
            var newClip = new AudioInformation(aPath, Path.GetFileNameWithoutExtension(aPath), importer.threeD, bitrate, importer.forceToMono, importer.format, importer.loadType);

            newClip.LastUpdated = updatedTime;

            audioInfo.AudioInfor.Add(newClip);
        }

        audioInfo.AudioInfor.RemoveAll(delegate(AudioInformation obj) {
            return(obj.LastUpdated < updatedTime);
        });

        // write file
        if (!WriteFile(audioInfo))
        {
            return;
        }

        LoadAndTranslateFile();
    }
        /// <summary>
        /// 再生する
        /// </summary>
        /// <remarks>AnimationEvent として呼び出されることを想定している</remarks>
        /// <param name="audioClip">再生対象の AudioClip</param>
        public void Play(AudioClip audioClip)
        {
            AudioInformation audioInformation = ScriptableObject.CreateInstance <AudioInformation>();

            audioInformation.AudioClip  = audioClip;
            audioInformation.ShouldLoop = false;
            this.StreamAnimationEvent
            .OnNext(
                new AnimationEvent()
            {
                objectReferenceParameter = audioInformation,
            }
                );
        }
Ejemplo n.º 14
0
    public void Awake()
    {
        //Check if there is already an instance of SoundManager
        if (Instance == null)
        {
            Instance = this;
        }

        MusicArray = Resources.LoadAll(WorldConstants.SOUND_AUDIO_DIR) as Object[];
        music      = MusicArray [0] as AudioInformation;

        //Subscribe our save and load functions.
        DataManager.onSave += this.Save;
        DataManager.onLoad += this.Load;
    }
Ejemplo n.º 15
0
        /// <summary>
        /// Gibt alle verbundenen Ressourcen frei. Insbesondere wird eine laufende
        /// Aufzeichnung beendet.
        /// </summary>
        protected override void OnDispose()
        {
            // Stop data receiption.
            StopReceivers(false);

            // Forget
            CurrentSourceConfiguration = null;
            CurrentSelection           = null;
            CurrentAudio = null;
            CurrentEntry = null;
            NextEntry    = null;

            // Reset EPG display
            ShowCurrentEntry();
        }
Ejemplo n.º 16
0
        private void BuildCache()
        {
            var filePaths = AssetDatabase.GetAllAssetPaths();

            var audioInfo = new AudioInfoData();

            _filterClips = null;
            _pageNumber  = 0;

            var updatedTime = DateTime.Now.Ticks;

            foreach (var aPath in filePaths)
            {
                if (!aPath.EndsWith(".wav", StringComparison.InvariantCultureIgnoreCase) &&
                    !aPath.EndsWith(".mp3", StringComparison.InvariantCultureIgnoreCase) &&
                    !aPath.EndsWith(".ogg", StringComparison.InvariantCultureIgnoreCase) &&
                    !aPath.EndsWith(".aiff", StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                // ReSharper disable once AccessToStaticMemberViaDerivedType
                var importer = (AudioImporter)AudioImporter.GetAtPath(aPath);

                // ReSharper disable once UseObjectOrCollectionInitializer
                AudioImporterSampleSettings settings = importer.defaultSampleSettings;
                var newClip = new AudioInformation(aPath, Path.GetFileNameWithoutExtension(aPath), importer.forceToMono, importer.loadInBackground, importer.preloadAudioData,
                                                   settings.loadType, settings.compressionFormat, settings.quality, settings.sampleRateSetting, int.Parse(settings.sampleRateOverride.ToString()));

                newClip.LastUpdated = updatedTime;

                audioInfo.AudioInfor.Add(newClip);
            }

            audioInfo.AudioInfor.RemoveAll(delegate(AudioInformation obj)
            {
                return(obj.LastUpdated < updatedTime);
            });

            // write file
            if (!WriteFile(audioInfo))
            {
                return;
            }

            LoadAndTranslateFile();
        }
Ejemplo n.º 17
0
    protected override bool Setup(byte[] data)
    {
        _offset = ReadWavHeaders(data);
        if (_wavContainer.Failed)
        {
            return(false);
        }

        float totalFrames = _wavContainer.FileLength / _wavContainer.BytesPerFrame;

        _wavContainer.FileLength = (int)totalFrames;
        AudioClip clip = AudioClip.Create("Streamed audio", _wavContainer.FileLength, _wavContainer.ChannelCount, _wavContainer.SampleRate, true, OnAudioRead);

        _audioInformation = new AudioInformation(clip);

        return(true);
    }
Ejemplo n.º 18
0
            public AudioItem(AudioInformation _Audio)
            {
                this._Audio = _Audio;
                BackColor   = Color.FromArgb(60, 60, 60);
                ForeColor   = Color.Black;
                Font        = new Font("Segoe UI", 10);
                Size        = new Size(100, 66);
                MinimumSize = new Size(390, 0);
                SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.UserPaint, true);
                SetStyle(ControlStyles.Selectable, false);

                tmrAnimation = new Timer
                {
                    Interval = 5,
                    Enabled  = false
                };
                tmrAnimation.Tick += tmrAnimation_OnTick;
            }
 /// <summary>
 /// Unity lifecycle: Start
 /// </summary>
 /// <remarks>イベント発火ストリームを Subscribe する</remarks>
 private void Start()
 {
     if (Application.isEditor)
     {
         SetAudioListenerIfNeeded();
     }
     this.StreamAnimationEvent
     .Subscribe(
         (animationEvent) => {
         AudioInformation audioInformation = animationEvent.objectReferenceParameter as AudioInformation;
         if (audioInformation == default(AudioInformation))
         {
             return;
         }
         this.PlayInternal(audioInformation.AudioClip, audioInformation.ShouldLoop);
     }
         );
 }
Ejemplo n.º 20
0
 public bool TestAudioFile(string path, out AudioInformation audioInformation)
 {
     audioInformation = null;
     try
     {
         using (var source = CodecFactory.Instance.GetCodec(path))
         {
             audioInformation = new AudioInformation
             {
                 Duration   = source.GetLength(),
                 SampleRate = source.WaveFormat.SampleRate
             };
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Ergänzt eine neue Tonspur.
        /// </summary>
        /// <param name="sender">Wird ignoriert.</param>
        /// <param name="e">Wird ignoriert.</param>
        private void cmdAddAudio_Click(object sender, EventArgs e)
        {
            // Create new
            AudioInformation audio = new AudioInformation {
                AudioType = AudioTypes.MP2, AudioStream = 0, Language = "Deutsch"
            };

            // Create list
            List <AudioInformation> audios = new List <AudioInformation>();

            // Fill list
            if (null != CurrentModifier.AudioStreams)
            {
                audios.AddRange(CurrentModifier.AudioStreams);
            }

            // Append new
            audios.Add(audio);

            // Push back
            CurrentModifier.AudioStreams = audios.ToArray();

            // New item
            AudioItem item = new AudioItem(audio);

            // Push back
            selAudio.Items.Add(item);

            // Select it
            selAudio.SelectedItem = item;

            // Update
            selAudio_SelectedIndexChanged(selAudio, EventArgs.Empty);

            // Enable edit
            txAudioLanguage.Enabled = true;
            selAudioType.Enabled    = true;
            selAudioPID.Enabled     = true;
        }
Ejemplo n.º 22
0
    private void ApplyClipChanges(AudioInformation info, bool writeChanges)
    {
        Selection.objects = new Object[] { }; // unselect to get "Apply" to work automatically.

        // ReSharper disable once AccessToStaticMemberViaDerivedType
        var importer = (AudioImporter)AudioImporter.GetAtPath(info.FullPath);

        importer.compressionBitrate = info.CompressionBitrate;

        importer.forceToMono = info.ForceMono;
        importer.format      = info.Format;
        importer.loadType    = info.LoadType;
        importer.threeD      = info.Is3D;

        AssetDatabase.ImportAsset(info.FullPath, ImportAssetOptions.ForceUpdate);
        info.HasChanged = true;

        if (writeChanges)
        {
            WriteFile(_clipList);
        }
    }
Ejemplo n.º 23
0
        public AudioItem AddItem(AudioInformation _Audio)
        {
            AudioItem Item = new AudioItem(_Audio)
            {
                Margin           = new Padding(7, 10, 7, 4),
                ContextMenuStrip = ContextMenuStrip,
                DownloadStatus   = AudioItem.DownloadStatuses.NotDownloaded,
                Checked          = true
            };

            Item.MouseUp   += onItemMouseUp;
            Item.MouseDown += onItemMouseDown;

            Invoke(new MethodInvoker(() =>
            {
                Controls.Add(Item);
                OnResize(null);

                Sort();
            }));

            return(Item);
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Erzeugt eine neue Beschreibung.
 /// </summary>
 /// <param name="information">Die zu verwaltenden Daten.</param>
 public AudioItem(AudioInformation information)
 {
     // Remember
     Information = information;
 }
Ejemplo n.º 25
0
 public bool TestAudioFile(string path, out AudioInformation audioInformation)
 {
     audioInformation = null;
     try
     {
         using (var source = CodecFactory.Instance.GetCodec(path))
         {
             audioInformation = new AudioInformation
             {
                 Duration = source.GetLength(),
                 SampleRate = source.WaveFormat.SampleRate
             };
             return true;
         }
     }
     catch (Exception)
     {
         return false;
     }
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Zeigt Bild, Ton und Videotext an.
        /// </summary>
        /// <param name="audio">Die zu verwendende Tonspur.</param>
        private void Activate(AudioInformation audio)
        {
            // Stop current
            StopReceivers(true);

            // Reset anything in queue
            Accessor.ClearBuffers();

            // Mode of operation
            bool mpeg4 = ((0 != CurrentSourceConfiguration.VideoStream) && (VideoTypes.H264 == CurrentSourceConfiguration.VideoType)), ac3 = false;

            // Configure video
            if (0 != CurrentSourceConfiguration.VideoStream)
            {
                VideoId = Device.AddConsumer(CurrentSourceConfiguration.VideoStream, StreamTypes.Video, Accessor.AddVideo);
            }

            // Use default audio
            if (null == audio)
            {
                if (CurrentSourceConfiguration.AudioTracks.Count > 0)
                {
                    audio = CurrentSourceConfiguration.AudioTracks[0];
                }
            }

            // Configure audio
            if (null != audio)
            {
                // Remember the type
                ac3 = (AudioTypes.AC3 == audio.AudioType);

                // Create the filter
                AudioId = Device.AddConsumer(audio.AudioStream, StreamTypes.Audio, Accessor.AddAudio);
            }

            // Remember for update
            CurrentAudio = audio;

            // Start streaming
            Device.SetConsumerState(VideoId, true);
            Device.SetConsumerState(AudioId, true);

            // Check for video text
            if (0 != CurrentSourceConfiguration.TextStream)
            {
                // Create the PES analyser
                TTXStream stream = new TTXStream(m_TTXConnector, (short)CurrentSourceConfiguration.TextStream, false);

                // Create the filter
                TextId = Device.AddConsumer(CurrentSourceConfiguration.TextStream, StreamTypes.VideoText, stream.AddPayload);

                // Start the filter
                Device.SetConsumerState(TextId, true);
            }

            // Now restart data transmission
            Accessor.StartGraph(mpeg4, ac3);

            // Enable service parser if we are allowed to to so
            if (!Profile.DisableProgramGuide)
            {
                if (!Profile.GetFilter(CurrentSelection.Source).DisableProgramGuide)
                {
                    Device.AddProgramGuideConsumer(ReceiveEPG);
                }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Gibt alle verbundenen Ressourcen frei. Insbesondere wird eine laufende
        /// Aufzeichnung beendet.
        /// </summary>
        protected override void OnDispose()
        {
            // Stop data receiption.
            StopReceivers( false );

            // Forget
            CurrentSourceConfiguration = null;
            CurrentSelection = null;
            CurrentAudio = null;
            CurrentEntry = null;
            NextEntry = null;

            // Reset EPG display
            ShowCurrentEntry();
        }
Ejemplo n.º 28
0
 private static void SelectClip(AudioInformation info)
 {
     Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(info.FullPath);
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Contains meta-data about a page.
        ///
        /// Protocols supported:
        /// The Open Graph protocol: http://ogp.me/
        /// </summary>
        /// <param name="Doc">HTML Document</param>
        public PageMetaData(HtmlDocument Doc)
        {
            List <ImageInformation> Images          = null;
            List <AudioInformation> Audio           = null;
            List <VideoInformation> Video           = null;
            List <string>           LocaleAlternate = null;
            ImageInformation        LastImage       = null;
            AudioInformation        LastAudio       = null;
            VideoInformation        LastVideo       = null;
            string Name;
            string Value;

            if (Doc.Meta != null)
            {
                foreach (Meta Meta in Doc.Meta)
                {
                    if (!Meta.HasAttributes)
                    {
                        continue;
                    }

                    Name = Value = null;

                    foreach (HtmlAttribute Attr in Meta.Attributes)
                    {
                        switch (Attr.Name)
                        {
                        case "property":
                            Name = Attr.Value;
                            break;

                        case "content":
                            Value = Attr.Value;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Value))
                    {
                        continue;
                    }

                    switch (Name)
                    {
                    case "og:title":
                        this.title = Value;
                        break;

                    case "twitter:title":
                        if (string.IsNullOrEmpty(this.title))
                        {
                            this.title = Value;
                        }
                        break;

                    case "og:type":
                        this.type = Value;
                        break;

                    case "twitter:card":
                        if (string.IsNullOrEmpty(this.type))
                        {
                            this.type = Value;
                        }
                        break;

                    case "og:url":
                        this.url = Value;
                        break;

                    case "og:image":
                    case "og:image:url":
                    case "twitter:image":
                        if (Images != null)
                        {
                            LastImage = null;

                            foreach (ImageInformation Image in Images)
                            {
                                if (Image.Url == Value)
                                {
                                    LastImage = Image;
                                    break;
                                }
                            }

                            if (LastImage != null)
                            {
                                break;
                            }
                        }

                        LastImage = new ImageInformation()
                        {
                            Url = Value
                        };

                        if (Images == null)
                        {
                            Images = new List <ImageInformation>();
                        }

                        Images.Add(LastImage);
                        break;

                    case "og:image:secure_url":
                        if (LastImage != null)
                        {
                            LastImage.SecureUrl = Value;
                        }
                        break;

                    case "og:image:type":
                        if (LastImage != null)
                        {
                            LastImage.ContentType = Value;
                        }
                        break;

                    case "og:image:width":
                        if (LastImage != null && int.TryParse(Value, out int i))
                        {
                            LastImage.Width = i;
                        }
                        break;

                    case "og:image:height":
                        if (LastImage != null && int.TryParse(Value, out i))
                        {
                            LastImage.Height = i;
                        }
                        break;

                    case "og:image:alt":
                    case "twitter:image:alt":
                        if (LastImage != null)
                        {
                            LastImage.Description = Value;
                        }
                        break;

                    case "og:audio":
                        LastAudio = new AudioInformation()
                        {
                            Url = Value
                        };

                        if (Audio == null)
                        {
                            Audio = new List <AudioInformation>();
                        }

                        Audio.Add(LastAudio);
                        break;

                    case "og:audio:secure_url":
                        if (LastAudio != null)
                        {
                            LastAudio.SecureUrl = Value;
                        }
                        break;

                    case "og:audio:type":
                        if (LastAudio != null)
                        {
                            LastAudio.ContentType = Value;
                        }
                        break;

                    case "og:description":
                        this.description = Value;
                        break;

                    case "twitter:description":
                    case "description":
                        if (string.IsNullOrEmpty(this.description))
                        {
                            this.description = Value;
                        }
                        break;

                    case "og:determiner":
                        this.determiner = Value;
                        break;

                    case "og:locale":
                        this.locale = Value;
                        break;

                    case "og:locale:alternate":
                        if (LocaleAlternate == null)
                        {
                            LocaleAlternate = new List <string>();
                        }

                        LocaleAlternate.Add(Value);
                        break;

                    case "og:site_name":
                        this.siteName = Value;
                        break;

                    case "og:video":
                        LastVideo = new VideoInformation()
                        {
                            Url = Value
                        };

                        if (Video == null)
                        {
                            Video = new List <VideoInformation>();
                        }

                        Video.Add(LastVideo);
                        break;

                    case "og:video:secure_url":
                        if (LastVideo != null)
                        {
                            LastVideo.SecureUrl = Value;
                        }
                        break;

                    case "og:video:type":
                        if (LastVideo != null)
                        {
                            LastVideo.ContentType = Value;
                        }
                        break;

                    case "og:video:width":
                        if (LastVideo != null && int.TryParse(Value, out i))
                        {
                            LastVideo.Width = i;
                        }
                        break;

                    case "og:video:height":
                        if (LastVideo != null && int.TryParse(Value, out i))
                        {
                            LastVideo.Height = i;
                        }
                        break;
                    }
                }
            }

            if (string.IsNullOrEmpty(this.title) && Doc.Title != null)
            {
                this.title = Doc.Title.InnerHtml.Trim();
            }

            this.images          = Images?.ToArray();
            this.audio           = Audio?.ToArray();
            this.video           = Video?.ToArray();
            this.localeAlternate = LocaleAlternate?.ToArray();
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Ergänzt eine neue Tonspur.
        /// </summary>
        /// <param name="sender">Wird ignoriert.</param>
        /// <param name="e">Wird ignoriert.</param>
        private void cmdAddAudio_Click( object sender, EventArgs e )
        {
            // Create new
            AudioInformation audio = new AudioInformation { AudioType = AudioTypes.MP2, AudioStream = 0, Language = "Deutsch" };

            // Create list
            List<AudioInformation> audios = new List<AudioInformation>();

            // Fill list
            if (null != CurrentModifier.AudioStreams)
                audios.AddRange( CurrentModifier.AudioStreams );

            // Append new
            audios.Add( audio );

            // Push back
            CurrentModifier.AudioStreams = audios.ToArray();

            // New item
            AudioItem item = new AudioItem( audio );

            // Push back
            selAudio.Items.Add( item );

            // Select it
            selAudio.SelectedItem = item;

            // Update
            selAudio_SelectedIndexChanged( selAudio, EventArgs.Empty );

            // Enable edit
            txAudioLanguage.Enabled = true;
            selAudioType.Enabled = true;
            selAudioPID.Enabled = true;
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Erzeugt eine neue Beschreibung.
 /// </summary>
 /// <param name="information">Die zu verwaltenden Daten.</param>
 public AudioItem( AudioInformation information )
 {
     // Remember
     Information = information;
 }
Ejemplo n.º 32
0
    private bool TranslateFromXml(XmlDocument xDoc)
    {
        _folderPaths.Clear();
        _folderPaths.Add("[All]");

        var files = xDoc.SelectNodes("/Files//File");

        // ReSharper disable once PossibleNullReferenceException
        if (files.Count == 0) {
            DTGUIHelper.ShowLargeBarAlert("You have no audio files in this project. Add some, then click 'Scan Project'.");
            return false;
        }

        try {
            // ReSharper disable once PossibleNullReferenceException
            _clipList.SearchFilter = xDoc.DocumentElement.Attributes["searchFilter"].Value;
            _clipList.SortColumn = (ClipSortColumn)Enum.Parse(typeof(ClipSortColumn), xDoc.DocumentElement.Attributes["sortColumn"].Value);
            _clipList.SortDir = (ClipSortDirection)Enum.Parse(typeof(ClipSortDirection), xDoc.DocumentElement.Attributes["sortDir"].Value);

            var currentPaths = new List<string>();

            for (var i = 0; i < files.Count; i++) {
                var aNode = files[i];
                // ReSharper disable once PossibleNullReferenceException
                var path = aNode.Attributes["path"].Value.Trim();
                var clipName = aNode.Attributes["name"].Value.Trim();
                var is3D = bool.Parse(aNode.Attributes["is3d"].Value);
                var compressionBitrate = int.Parse(aNode.Attributes["bitRate"].Value);
                var forceMono = bool.Parse(aNode.Attributes["forceMono"].Value);

                var format = (AudioImporterFormat)Enum.Parse(typeof(AudioImporterFormat), aNode.Attributes["format"].Value);
                var loadType = (AudioImporterLoadType)Enum.Parse(typeof(AudioImporterLoadType), aNode.Attributes["loadType"].Value);

                currentPaths.Add(path);

                var folderPath = Path.GetDirectoryName(path);
                if (!_folderPaths.Contains(folderPath)) {
                    _folderPaths.Add(folderPath);
                }

                var matchingClip = _clipList.AudioInfor.Find(delegate(AudioInformation obj) {
                    return obj.FullPath == path;
                });

                if (matchingClip == null) {
                    var aud = new AudioInformation(path, clipName, is3D, compressionBitrate, forceMono, format, loadType);
                    _clipList.AudioInfor.Add(aud);
                } else {
                    matchingClip.OrigIs3D = is3D;
                    matchingClip.OrigFormat = format;
                    matchingClip.OrigLoadType = loadType;
                    matchingClip.OrigForceMono = forceMono;
                    matchingClip.OrigCompressionBitrate = compressionBitrate;
                }

                _clipList.NeedsRefresh = false;
            }

            // delete clips no longer in the XML
            _clipList.AudioInfor.RemoveAll(delegate(AudioInformation obj) {
                return !currentPaths.Contains(obj.FullPath);
            });
        }
        catch {
            DTGUIHelper.ShowRedError("Could not translate XML from cache file. Please click 'Scan Project'.");
            return false;
        }

        return true;
    }
Ejemplo n.º 33
0
    private void BuildCache()
    {
        var filePaths = AssetDatabase.GetAllAssetPaths();

        var audioInfo = new AudioInfoData();
        _filterClips = null;
        _pageNumber = 0;

        var updatedTime = DateTime.Now.Ticks;

        foreach (var aPath in filePaths) {
            if (!aPath.EndsWith(".wav", StringComparison.InvariantCultureIgnoreCase)
                && !aPath.EndsWith(".mp3", StringComparison.InvariantCultureIgnoreCase)
                && !aPath.EndsWith(".ogg", StringComparison.InvariantCultureIgnoreCase)
                && !aPath.EndsWith(".aiff", StringComparison.InvariantCultureIgnoreCase)) {

                continue;
            }

            // ReSharper disable once AccessToStaticMemberViaDerivedType
            var importer = (AudioImporter)AudioImporter.GetAtPath(aPath);

            var bitrate = importer.compressionBitrate;

            if (bitrate < 0) {
                bitrate = 156000;
            }

            // ReSharper disable once UseObjectOrCollectionInitializer
            var newClip = new AudioInformation(aPath, Path.GetFileNameWithoutExtension(aPath), importer.threeD, bitrate, importer.forceToMono, importer.format, importer.loadType);

            newClip.LastUpdated = updatedTime;

            audioInfo.AudioInfor.Add(newClip);
        }

        audioInfo.AudioInfor.RemoveAll(delegate(AudioInformation obj) {
            return obj.LastUpdated < updatedTime;
        });

        // write file
        if (!WriteFile(audioInfo)) {
            return;
        }

        LoadAndTranslateFile();
    }
Ejemplo n.º 34
0
    private void ApplyClipChanges(AudioInformation info, bool writeChanges)
    {
        Selection.objects = new Object[] { }; // unselect to get "Apply" to work automatically.

        // ReSharper disable once AccessToStaticMemberViaDerivedType
        var importer = (AudioImporter)AudioImporter.GetAtPath(info.FullPath);

        importer.compressionBitrate = info.CompressionBitrate;

        importer.forceToMono = info.ForceMono;
        importer.format = info.Format;
        importer.loadType = info.LoadType;
        importer.threeD = info.Is3D;

        AssetDatabase.ImportAsset(info.FullPath, ImportAssetOptions.ForceUpdate);
        info.HasChanged = true;

        if (writeChanges) {
            WriteFile(_clipList);
        }
    }
Ejemplo n.º 35
0
        //[End]
        
        private static async Task<AudioInformation> ParseVideoFromHTML(string html)
        {
            try
            {
                // Parse basic video information from the HTML
                string url = new Regex(URL_PATTERN).Match(html).Groups[1].Value;
                string title = new Regex(TITLE_PATTERN).Match(html).Groups[1].Value;
                string description = new Regex(DESCRIPTION_PATTERN).Match(html).Groups[1].Value;
                string thumbnailURL = new Regex(THUMBNAIL_PATTERN).Match(html).Groups[1].Value;

                // Make sure that the title and description don't contain any HTML-escaped characters like &amp;
                title = WebUtility.HtmlDecode(title);
                description = WebUtility.HtmlDecode(description);

                if (url.Contains("&")) url = url.Split('&')[0]; // If the URL contains more stuff in the query string, get rid of it

                // Separate the JSON string, which is what we need for the download URLs and qualities
                string jsonString = html.Split(new[] { "ytplayer.config = " }, StringSplitOptions.None)[1];
                jsonString = jsonString.Split(new []{"};"}, StringSplitOptions.None)[0] + "}";

                // Parse video information from the JSON
                dynamic json = new JavaScriptSerializer().Deserialize<object>(jsonString);
                string[] keywords = json["args"]["keywords"].Split(',');
                string[] adaptive_fmts = json["args"]["adaptive_fmts"].Split(new[] { "," }, StringSplitOptions.None);

                // Create a dictionary with different qualities, formats and URL's
                Dictionary<Tuple<FileFormat, AudioBitrate>, string> availableQualities = new Dictionary<Tuple<FileFormat, AudioBitrate>, string>();
                foreach (string stream in adaptive_fmts)
                {
                    if (!stream.Contains("url=")) continue;
                    if (!stream.Contains("itag=")) continue;

                    string formatString = Uri.UnescapeDataString(parseFieldFromQueryString("type", stream));
                    if(!isAudio(formatString)) continue;

                    string videoURL = Uri.UnescapeDataString(parseFieldFromQueryString("url", stream));
                    string itag = Uri.UnescapeDataString(parseFieldFromQueryString("itag", stream));
                    AudioBitrate bitrate = parseBitrate(itag);
                    FileFormat format = parseFormat(formatString);

                    Tuple<FileFormat, AudioBitrate> qualityTuple = Tuple.Create(format, bitrate);
                    if(!availableQualities.ContainsKey(qualityTuple)) availableQualities.Add(qualityTuple, videoURL);

                }

                // Download the thumbnail
                Image thumbnail;
                using (var http = new HttpClient())
                {
                    thumbnail = Image.FromStream(new MemoryStream(await http.GetByteArrayAsync(thumbnailURL)));
                }

                // Create the video instance
                AudioInformation audioInformation = new AudioInformation
                {
                    URL = url,
                    Title = title,
                    Description = description,
                    Keywords = keywords,
                    Thumbnail = thumbnail,
                    AvailableQualities = availableQualities
                };

                foreach (Tuple<FileFormat, AudioBitrate> qualityTuple in availableQualities.Keys)
                {
                    Console.WriteLine(qualityTuple.ToString());
                }

                // And return it :)
                return audioInformation;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return null;
            }
        }
Ejemplo n.º 36
0
 void Awake()
 {
     myTarget = (AudioInformation)target;
 }
Ejemplo n.º 37
0
        /// <summary>
        /// Zeigt Bild, Ton und Videotext an.
        /// </summary>
        /// <param name="audio">Die zu verwendende Tonspur.</param>
        private void Activate( AudioInformation audio )
        {
            // Stop current
            StopReceivers( true );

            // Reset anything in queue
            Accessor.ClearBuffers();

            // Mode of operation
            bool mpeg4 = ((0 != CurrentSourceConfiguration.VideoStream) && (VideoTypes.H264 == CurrentSourceConfiguration.VideoType)), ac3 = false;

            // Configure video
            if (0 != CurrentSourceConfiguration.VideoStream)
                VideoId = Device.AddConsumer( CurrentSourceConfiguration.VideoStream, StreamTypes.Video, Accessor.AddVideo );

            // Use default audio
            if (null == audio)
                if (CurrentSourceConfiguration.AudioTracks.Count > 0)
                    audio = CurrentSourceConfiguration.AudioTracks[0];

            // Configure audio
            if (null != audio)
            {
                // Remember the type
                ac3 = (AudioTypes.AC3 == audio.AudioType);

                // Create the filter
                AudioId = Device.AddConsumer( audio.AudioStream, StreamTypes.Audio, Accessor.AddAudio );
            }

            // Remember for update
            CurrentAudio = audio;

            // Start streaming
            Device.SetConsumerState( VideoId, true );
            Device.SetConsumerState( AudioId, true );

            // Check for video text
            if (0 != CurrentSourceConfiguration.TextStream)
            {
                // Create the PES analyser
                TTXStream stream = new TTXStream( m_TTXConnector, (short) CurrentSourceConfiguration.TextStream, false );

                // Create the filter
                TextId = Device.AddConsumer( CurrentSourceConfiguration.TextStream, StreamTypes.VideoText, stream.AddPayload );

                // Start the filter
                Device.SetConsumerState( TextId, true );
            }

            // Now restart data transmission
            Accessor.StartGraph( mpeg4, ac3 );

            // Enable service parser if we are allowed to to so
            if (!Profile.DisableProgramGuide)
                if (!Profile.GetFilter( CurrentSelection.Source ).DisableProgramGuide)
                    Device.AddProgramGuideConsumer( ReceiveEPG );
        }
Ejemplo n.º 38
0
    private bool TranslateFromXml(XmlDocument xDoc)
    {
        _folderPaths.Clear();
        _folderPaths.Add("[All]");

        var files = xDoc.SelectNodes("/Files//File");

        // ReSharper disable once PossibleNullReferenceException
        if (files.Count == 0)
        {
            DTGUIHelper.ShowLargeBarAlert("You have no audio files in this project. Add some, then click 'Scan Project'.");
            return(false);
        }

        try {
            // ReSharper disable once PossibleNullReferenceException
            _clipList.SearchFilter = xDoc.DocumentElement.Attributes["searchFilter"].Value;
            _clipList.SortColumn   = (ClipSortColumn)Enum.Parse(typeof(ClipSortColumn), xDoc.DocumentElement.Attributes["sortColumn"].Value);
            _clipList.SortDir      = (ClipSortDirection)Enum.Parse(typeof(ClipSortDirection), xDoc.DocumentElement.Attributes["sortDir"].Value);

            var currentPaths = new List <string>();

            for (var i = 0; i < files.Count; i++)
            {
                var aNode = files[i];
                // ReSharper disable once PossibleNullReferenceException
                var path               = aNode.Attributes["path"].Value.Trim();
                var clipName           = aNode.Attributes["name"].Value.Trim();
                var is3D               = bool.Parse(aNode.Attributes["is3d"].Value);
                var compressionBitrate = int.Parse(aNode.Attributes["bitRate"].Value);
                var forceMono          = bool.Parse(aNode.Attributes["forceMono"].Value);

                var format   = (AudioImporterFormat)Enum.Parse(typeof(AudioImporterFormat), aNode.Attributes["format"].Value);
                var loadType = (AudioImporterLoadType)Enum.Parse(typeof(AudioImporterLoadType), aNode.Attributes["loadType"].Value);

                currentPaths.Add(path);

                var folderPath = Path.GetDirectoryName(path);
                if (!_folderPaths.Contains(folderPath))
                {
                    _folderPaths.Add(folderPath);
                }

                var matchingClip = _clipList.AudioInfor.Find(delegate(AudioInformation obj) {
                    return(obj.FullPath == path);
                });

                if (matchingClip == null)
                {
                    var aud = new AudioInformation(path, clipName, is3D, compressionBitrate, forceMono, format, loadType);
                    _clipList.AudioInfor.Add(aud);
                }
                else
                {
                    matchingClip.OrigIs3D               = is3D;
                    matchingClip.OrigFormat             = format;
                    matchingClip.OrigLoadType           = loadType;
                    matchingClip.OrigForceMono          = forceMono;
                    matchingClip.OrigCompressionBitrate = compressionBitrate;
                }

                _clipList.NeedsRefresh = false;
            }

            // delete clips no longer in the XML
            _clipList.AudioInfor.RemoveAll(delegate(AudioInformation obj) {
                return(!currentPaths.Contains(obj.FullPath));
            });
        }
        catch {
            DTGUIHelper.ShowRedError("Could not translate XML from cache file. Please click 'Scan Project'.");
            return(false);
        }

        return(true);
    }
Ejemplo n.º 39
0
        private async Task <PlayableBase> GetTrack(FileInfo fileInfo, List <string> supportedExtensions)
        {
            var extension = fileInfo.Extension.Remove(0, 1);

            //--- STEP 1: Check the track ---
            //Check the extension
            if (!supportedExtensions.Any(x => string.Equals(x, extension, StringComparison.OrdinalIgnoreCase)))
            {
                return(null);
            }

            AudioInformation audioInformation = null;

            //Check the file
            if (
                !(await
                  Task.Run(
                      () =>
                      _musicDataManager.MusicManager.AudioEngine.TestAudioFile(fileInfo.FullName,
                                                                               out audioInformation)))) //If the audio engine can't open the track, skip
            {
                return(null);
            }

            LocalPlayable track;

            //--- STEP 2: Get information from the file ---
            //Search if track is already in the database
            if (SearchTrack(fileInfo.FullName, out track))
            {
                return(track);
            }

            //Create a new track with some information we already have
            track = new LocalPlayable
            {
                Extension  = extension.ToUpper(),
                TrackPath  = fileInfo.FullName,
                Duration   = audioInformation.Duration,
                SampleRate = Math.Round(audioInformation.SampleRate / 1000d, 1)
            };

            string filenameArtistName = null;
            string tagArtistName      = null;
            string internetArtistName = null;

            string albumName = null;
            string title     = null;

            /*
             *  Information priority:
             *  1. Tag
             *  2. Internet
             *  3. Filename
             */

            try
            {
                //Let's have a look in the tags
                using (var tagLibInfo = File.Create(fileInfo.FullName)) //We look into the tags. Perhaps we'll find something interesting
                {
                    track.Title = tagLibInfo.Tag.Title;
                    if (!string.IsNullOrEmpty(tagLibInfo.Tag.MusicBrainzArtistId))
                    {
                        track.Artist = await GetArtistByMusicBrainzId(tagLibInfo.Tag.MusicBrainzArtistId); //Ui, that's awesome
                    }
                    else
                    {
                        tagArtistName = tagLibInfo.Tag.FirstPerformer ?? tagLibInfo.Tag.FirstAlbumArtist; //Both is okay
                    }
                    if (tagLibInfo.Tag.Pictures.Any())
                    {
                        if (tagLibInfo.Tag.Pictures.Count() > 1)
                        {
                            Debug.Print("tagLibInfo.Tag.Pictures.Length > 1");
                        }

                        track.Cover = new TagImage(fileInfo.FullName);
                    }

                    track.Bitrate = tagLibInfo.Properties.AudioBitrate;
                    albumName     = tagLibInfo.Tag.Album;
                }
            }
            catch (Exception)
            {
                //Do nothing
            }

            //At the next step, the title must have a value
            if (track.Title == null || (tagArtistName == null && track.Artist == null))
            {
                var match = Regex.Match(Path.GetFileNameWithoutExtension(fileInfo.FullName), @"(?<artist>([a-zA-Z].+?)) - (?<title>(.[^\(\[-]+))");
                if (match.Success)
                {
                    title = match.Groups["title"].Value.Trim();
                    if (tagArtistName == null)
                    {
                        filenameArtistName = match.Groups["artist"].Value;
                    }
                }
                else
                {
                    title = Path.GetFileNameWithoutExtension(fileInfo.FullName);
                    if (tagArtistName == null)
                    {
                        filenameArtistName = string.Empty;
                    }
                }
            }

            //Now we search the track in the internet. If we have find something, we set all information which has to be set
            var trackInfo = await _musicDataManager.LastfmApi.GetTrackInformation(track.Title ?? title, track.Artist?.Name ?? tagArtistName ?? filenameArtistName);

            if (trackInfo != null)
            {
                if (track.Title == null)
                {
                    track.Title = trackInfo.Name;
                }

                if (!string.IsNullOrEmpty(trackInfo.MusicBrainzId))
                {
                    var temp = SearchTrackByMusicBrainzId(trackInfo.MusicBrainzId);
                    if (temp != null)
                    {
                        return(temp);
                    }

                    //Check if we already have a track with this id
                    track.MusicBrainzId = trackInfo.MusicBrainzId;
                }

                if (track.Cover == null)
                {
                    track.Cover = trackInfo.CoverImage;
                }

                if (track.Artist == null)
                {
                    track.Artist =
                        await SearchArtist(tagArtistName, trackInfo.Artist, filenameArtistName, track.MusicBrainzId);

                    if (track.Artist == null)
                    {
                        internetArtistName = trackInfo.Artist;
                    }
                }
            }
            else if (track.Title == null)
            {
                track.Title = title;
            }

            if (track.Artist == null)
            {
                var name = tagArtistName ?? internetArtistName ?? filenameArtistName;
                if (!string.IsNullOrEmpty(name))
                {
                    var artist = await _musicDataManager.LastfmApi.SearchArtistOnline(name);

                    track.Artist = artist ?? new Artist(name);
                }
                else
                {
                    track.Artist = _musicDataManager.Artists.UnknownArtist;
                }
            }

            if (!_musicDataManager.Artists.ArtistDictionary.ContainsKey(track.Artist.Guid))
            {
                await _musicDataManager.Artists.AddArtist(track.Artist);
            }

            if (!string.IsNullOrWhiteSpace(albumName))
            {
                track.Album =
                    _musicDataManager.Albums.Collection.FirstOrDefault(
                        x =>
                        string.Equals(x.Value.Name, albumName,
                                      StringComparison.OrdinalIgnoreCase)).Value;

                if (track.Album == null)
                {
                    var album = new Album
                    {
                        Name = albumName,
                        Guid = Guid.NewGuid()
                    };

                    await _musicDataManager.Albums.AddAlbum(album);

                    track.Album = album;
                }

                if (track.Artist != _musicDataManager.Artists.UnknownArtist &&
                    !track.Album.Artists.Contains(track.Artist))
                {
                    track.Album.Artists.Add(track.Artist);
                    await _musicDataManager.Albums.UpdateAlbumArtists(track.Album);
                }
            }

            await _musicDataManager.Tracks.AddTrack(track);

            return(track);
        }
Ejemplo n.º 40
0
 private static void SelectClip(AudioInformation info)
 {
     Selection.activeObject = AssetDatabase.LoadMainAssetAtPath(info.FullPath);
 }
Ejemplo n.º 41
0
 private static void RevertChanges(AudioInformation info)
 {
     info.CompressionBitrate = info.OrigCompressionBitrate;
     info.ForceMono = info.OrigForceMono;
     info.Format = info.OrigFormat;
     info.LoadType = info.OrigLoadType;
     info.Is3D = info.OrigIs3D;
 }