/// <summary> /// Creates a new Sound Resource based on the specified AudioData, saves it and returns a reference to it. /// </summary> /// <param name="baseRes"></param> /// <returns></returns> public static ContentRef<Sound> CreateFromAudioData(ContentRef<AudioData> baseRes) { string resPath = PathHelper.GetFreePath(baseRes.FullName, FileExt); Sound res = new Sound(baseRes); res.Save(resPath); return res; }
protected void GeneratePreview() { int ovLen = this.value != null && this.value.OggVorbisData != null ? this.value.OggVorbisData.Length : 0; if (this.prevImageValue == ovLen) return; this.prevImageValue = ovLen; this.StopPreviewSound(); if (this.prevSound != null) this.prevSound.Dispose(); this.prevSound = null; if (this.prevImage != null) this.prevImage.Dispose(); this.prevImage = null; if (this.value != null) { this.prevImage = PreviewProvider.GetPreviewImage(this.value, this.ClientRectangle.Width - 2, this.ClientRectangle.Height - 2, PreviewSizeMode.FixedHeight); if (this.prevImage != null) { var avgColor = this.prevImage.GetAverageColor(); this.prevImageLum = avgColor.GetLuminance(); } this.prevSound = PreviewProvider.GetPreviewSound(this.value); } this.Invalidate(); }
/// <summary> /// Creates a new Sound Resource based on the specified AudioData, saves it and returns a reference to it. /// </summary> /// <param name="baseRes"></param> /// <param name="name"></param> /// <returns></returns> public static ContentRef<Sound> CreateFromAudioData(IEnumerable<ContentRef<AudioData>> baseRes, string name = null) { if (!baseRes.Any()) return null; string basePath = baseRes.FirstOrDefault().FullName; if (name != null) basePath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(basePath), name); string resPath = PathHelper.GetFreePath(basePath, FileExt); Sound res = new Sound(baseRes); res.Save(resPath); return res; }
private static bool IsMatch(AudioData source, Sound target) { return target.Data != null && target.Data.Contains(source); }