private void DrawSpectra(Canvas2 frameImg, SpectrumGraph0001 sg, ShadowSpectraData ss) { using (Graphics g = frameImg.GetGraphics(false)) { int dr_l = 0; int dr_t = MARGIN_TB; int dr_w = frameImg.GetWidth(); int dr_h = frameImg.GetHeight() - MARGIN_TB * 2; for (int index = 0; index < sg.Spectra.Length; index++) { int x = index * (BAR_WIDTH + BAR_INTERVAL) + BAR_INTERVAL; int w = BAR_WIDTH; double v1 = ss.ShadowSpectra[index]; double v2 = sg.Spectra[index]; v1 *= 0.5; // 要調整 v2 *= 0.5; // 要調整 int h1 = DoubleTools.ToInt(v1 * dr_h); int h2 = DoubleTools.ToInt(v2 * dr_h); int y1 = dr_h - h1; int y2 = dr_h - h2; g.FillRectangle(new SolidBrush(Color.FromArgb(128, 255, 255, 255)), dr_l + x, dr_t + y1, w, h1); g.FillRectangle(new SolidBrush(Color.White), dr_l + x, dr_t + y2, w, h2); } } }
private void DrawSpectra(Canvas2 frameImg, SpectrumGraph0001 sg, ShadowSpectraData ss) { using (Graphics g = frameImg.GetGraphics(false)) { int dr_l = 10; int dr_t = 10; int dr_w = frameImg.GetWidth() - 20; int dr_h = frameImg.GetHeight() - 20; for (int index = 0; index < sg.Spectra.Length; index++) { int x1 = (((index * 3 + 0) * dr_w) / (sg.Spectra.Length * 3 - 2)); int x2 = (((index * 3 + 1) * dr_w) / (sg.Spectra.Length * 3 - 2)); int w = x2 - x1; double v1 = ss.ShadowSpectra[index]; double v2 = sg.Spectra[index]; v1 /= 2.0; // 要調整 v2 /= 2.0; // 要調整 int h1 = DoubleTools.ToInt(v1 * dr_h); int h2 = DoubleTools.ToInt(v2 * dr_h); int y1 = dr_h - h1; int y2 = dr_h - h2; g.FillRectangle(new SolidBrush(Color.FromArgb(128, 255, 255, 255)), dr_l + x1, dr_t + y1, w, h1); g.FillRectangle(new SolidBrush(Color.White), dr_l + x1, dr_t + y2, w, h2); } } }
public override IEnumerable <Canvas2> GetImageSequence() { ShadowSpectraData ss = new ShadowSpectraData(); for (; ;) { this.Wave.SetWavPart(DoubleTools.ToInt((this.Frame * 1.0 / AudioPicMP4Props.FPS + AudioPicMP4Props.AUDIO_DELAY_SEC) * this.Wave.WavHz)); SpectrumGraph0001 sg = new SpectrumGraph0001(hz => this.Wave.GetSpectrum(hz)); ss.Projection(sg.Spectra); int w = sg.Spectra.Length * (BAR_WIDTH + BAR_INTERVAL) + BAR_INTERVAL; Canvas2 frameImg = new Canvas2(w, AudioPicMP4Props.VIDEO_H); PictureUtils.Fill(frameImg, Color.Transparent); this.DrawSpectra(frameImg, sg, ss); yield return(frameImg); } }
public override IEnumerable <Canvas2> GetImageSequence() { ShadowSpectraData ssL = new ShadowSpectraData(); ShadowSpectraData ssR = new ShadowSpectraData(); for (; ;) { this.Wave.SetWavPart(DoubleTools.ToInt((this.Frame * 1.0 / AudioPicMP4Props.FPS + AudioPicMP4Props.AUDIO_DELAY_SEC) * this.Wave.WavHz)); SpectrumGraph0001 sgL = new SpectrumGraph0001(hz => this.Wave.GetSpectrum_L(hz)) { R1 = 0.5, R2 = 0.5 }; SpectrumGraph0001 sgR = new SpectrumGraph0001(hz => this.Wave.GetSpectrum_R(hz)) { R1 = 0.5, R2 = 0.5 }; ssL.Projection(sgL.Spectra); ssR.Projection(sgR.Spectra); int w = sgL.Spectra.Length * (BAR_WIDTH + BAR_INTERVAL) + BAR_INTERVAL; Canvas2 frameImg_L = new Canvas2(w, AudioPicMP4Props.VIDEO_H); Canvas2 frameImg_R = new Canvas2(w, AudioPicMP4Props.VIDEO_H); PictureUtils.Fill(frameImg_L, Color.Transparent); PictureUtils.Fill(frameImg_R, Color.Transparent); this.DrawSpectra(frameImg_L, sgL, ssL, Color.FromArgb(255, 255, 200), false); this.DrawSpectra(frameImg_R, sgR, ssR, Color.FromArgb(200, 255, 255), true); Canvas2 frameImg = new Canvas2(w * 2, AudioPicMP4Props.VIDEO_H); PictureUtils.Paste(frameImg, frameImg_L, 0, 0, w, AudioPicMP4Props.VIDEO_H); PictureUtils.Paste(frameImg, frameImg_R, w, 0, w, AudioPicMP4Props.VIDEO_H); yield return(frameImg); } }
public void MakeVideo(WaveData wave, WorkingDir wd, Action <Canvas2> addImage) { this.DiscJacket = new Canvas2(this.DiscJacketFile); this.BluredDiscJacket = PictureUtils.Blur(this.DiscJacket, 5); // 要調整 this.MarginedDiscJacket = PictureUtils.PutMargin(this.DiscJacket); ShadowSpectraData ss = new ShadowSpectraData(); FadeInOutData f1 = new FadeInOutData() { MaxValue = 20 }; FadeInOutData f2 = new FadeInOutData(); f1.Rate = 1.0; int frameNum = DoubleTools.ToInt((wave.Length * 1.0 / wave.WavHz) * AudioPicMP4Props.FPS); for (int frame = 0; frame < frameNum; frame++) { if (frame == 2 * AudioPicMP4Props.FPS) { f1.TargetRate = 0.0; } if (frame == frameNum - 10 - f2.MaxValue) { f2.TargetRate = 1.0; } f1.Approach(); f2.Approach(); double rate = frame * 1.0 / (frameNum - 1); double invRate = 1.0 - rate; double r1 = 1.0 + 0.2 * rate; double r2 = 1.0 + 0.1 * invRate; D4Rect wallRect; D4Rect frntRect; { D2Size size = Utils.TangentSize( new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), new D2Size(this.DiscJacket.GetWidth(), this.DiscJacket.GetHeight()), false ); size.W *= r1; size.H *= r1; wallRect = Utils.Centering(new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), size); } { D2Size size = Utils.TangentSize( new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), new D2Size(this.DiscJacket.GetWidth(), this.DiscJacket.GetHeight()), true ); size.W *= r2; size.H *= r2; // マージン分 size.W *= this.MarginedDiscJacket.GetWidth() * 1.0 / this.DiscJacket.GetWidth(); size.H *= this.MarginedDiscJacket.GetHeight() * 1.0 / this.DiscJacket.GetHeight(); frntRect = Utils.Centering(new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), size); } Canvas2 frameImg = new Canvas2(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H); PictureUtils.Paste(frameImg, this.BluredDiscJacket, wallRect); PictureUtils.Filter(frameImg, Color.Black, 0.5); // 要調整 PictureUtils.Paste(frameImg, this.MarginedDiscJacket, frntRect); PictureUtils.Filter(frameImg, Color.Black, 0.1); // 要調整 PictureUtils.Filter(frameImg, Color.Black, f1.Rate); // 背景カーテン wave.SetWavPart(DoubleTools.ToInt((frame * 1.0 / AudioPicMP4Props.FPS + AudioPicMP4Props.AUDIO_DELAY_SEC) * wave.WavHz)); SpectrumGraph0001 sg = new SpectrumGraph0001(hz => wave.GetSpectrum(hz)); ss.Projection(sg.Spectra); this.DrawSpectra(frameImg, sg, ss); PictureUtils.Filter(frameImg, Color.Black, f2.Rate); // 前景カーテン addImage(frameImg); } }
private void MakeMovie_Main() { this.DiscJacket = new Canvas2(this.DiscJacketFile); this.BluredDiscJacket = PictureUtils.Blur(this.DiscJacket, 5); // 要調整 this.MarginedDiscJacket = PictureUtils.PutMargin(this.DiscJacket); { string wavFile = this.WD.GetPath("audio.wav"); string masterWavFile = this.WD.GetPath("audio2.wav"); FFmpegConv.MakeWavFile(this.SourceMediaFile, wavFile); if (this.MasterFlag && MasterUtils.Mastering(wavFile, masterWavFile)) { this.Wave = new WaveData(masterWavFile); this.FFmpeg.Audio.PutAudioFile(masterWavFile); } else { this.Wave = new WaveData(wavFile); this.FFmpeg.Audio.PutAudioFile(this.SourceMediaFile); } } ShadowSpectraData ss = new ShadowSpectraData(); FadeInOutData f1 = new FadeInOutData() { MaxValue = 20 }; FadeInOutData f2 = new FadeInOutData(); f1.Rate = 1.0; int frameNum = DoubleTools.ToInt((this.Wave.Length * 1.0 / this.Wave.WavHz) * AudioPicMP4Props.FPS); for (int frame = 0; frame < frameNum; frame++) { if (frame == 2 * AudioPicMP4Props.FPS) { f1.TargetRate = 0.0; } if (frame == frameNum - 10 - f2.MaxValue) { f2.TargetRate = 1.0; } f1.Approach(); f2.Approach(); double rate = frame * 1.0 / (frameNum - 1); double invRate = 1.0 - rate; double r1 = 1.0 + 0.2 * rate; double r2 = 1.0 + 0.1 * invRate; D4Rect wallRect; D4Rect frntRect; { D2Size size = Utils.TangentSize( new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), new D2Size(this.DiscJacket.GetWidth(), this.DiscJacket.GetHeight()), false ); size.W *= r1; size.H *= r1; wallRect = Utils.Centering(new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), size); } { D2Size size = Utils.TangentSize( new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), new D2Size(this.DiscJacket.GetWidth(), this.DiscJacket.GetHeight()), true ); size.W *= r2; size.H *= r2; // マージン分 size.W *= this.MarginedDiscJacket.GetWidth() * 1.0 / this.DiscJacket.GetWidth(); size.H *= this.MarginedDiscJacket.GetHeight() * 1.0 / this.DiscJacket.GetHeight(); frntRect = Utils.Centering(new D2Size(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H), size); } Canvas2 frameImg = new Canvas2(AudioPicMP4Props.VIDEO_W, AudioPicMP4Props.VIDEO_H); PictureUtils.Paste(frameImg, this.BluredDiscJacket, wallRect); PictureUtils.Filter(frameImg, Color.Black, 0.5); // 要調整 PictureUtils.Paste(frameImg, this.MarginedDiscJacket, frntRect); PictureUtils.Filter(frameImg, Color.Black, 0.1); // 要調整 PictureUtils.Filter(frameImg, Color.Black, f1.Rate); // 背景カーテン this.Wave.SetWavPart(DoubleTools.ToInt((frame * 1.0 / AudioPicMP4Props.FPS + AudioPicMP4Props.AUDIO_DELAY_SEC) * this.Wave.WavHz)); SpectrumGraph0001 sg = new SpectrumGraph0001(hz => this.Wave.GetSpectrum(hz)); ss.Projection(sg.Spectra); this.DrawSpectra(frameImg, sg, ss); PictureUtils.Filter(frameImg, Color.Black, f2.Rate); // 前景カーテン frameImg.Save(this.FFmpeg.GetImageFile(frame), ImageFormat.Jpeg, AudioPicMP4Props.JPEG_QUALITY); GC.Collect(); } this.FFmpeg.MakeMovie(); File.Copy(this.FFmpeg.GetMovieFile(), this.DestMP4File); }
public void Draw(double[] spectra) { if (spectra.Length != 90) { throw null; // souteigai !!! } if (this.ShadowSpectra == null) { this.ShadowSpectra = new ShadowSpectraData(); } this.ShadowSpectra.Projection(spectra); DDSubScreenUtils.ChangeDrawScreen(this.GraphScreen); DX.ClearDrawScreen(); for (int c = 0; c < 30; c++) { double v = this.ShadowSpectra.ShadowSpectra[c * 3 + 0] + this.ShadowSpectra.ShadowSpectra[c * 3 + 1] + this.ShadowSpectra.ShadowSpectra[c * 3 + 2]; v /= 3.0; int x1 = c * 30; int x2 = x1 + 10; int y1 = (int)((1.0 - v) * 600); int y2 = 600; if (y1 + 1 < y2) { DDDraw.SetBright(0.4, 0.5, 0.6); DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, x1, y1, x2 - x1, y2 - y1); DDDraw.Reset(); } } for (int c = 0; c < 30; c++) { double v = spectra[c * 3 + 0] + spectra[c * 3 + 1] + spectra[c * 3 + 2]; v /= 3.0; int x1 = c * 30; int x2 = x1 + 10; int y1 = (int)((1.0 - v) * 600); int y2 = 600; if (y1 + 1 < y2) { DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, x1, y1, x2 - x1, y2 - y1); } } DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, 0, 620, 880, 10); DDFontUtils.DrawString(0, 640, "小田和正", DDFontUtils.GetFont("メイリオ", 80)); DDFontUtils.DrawString(270, 740, "ラブ・ストーリーは突然に", DDFontUtils.GetFont("メイリオ", 50)); DDFontUtils.DrawString(30, 840, "『 東京ラブストーリー ( 1991 ) 』 主題歌", DDFontUtils.GetFont("メイリオ", 40)); DDSubScreenUtils.ChangeDrawScreen(this.Screen); DX.ClearDrawScreen(); DDDraw.DrawBegin(DDPictureLoaders2.Wrapper(this.GraphScreen), 500, 500); DDDraw.SetBright(0, 0, 0); DDDraw.DrawEnd(); DDDraw.Reset(); DX.GraphFilter(this.Screen.GetHandle(), DX.DX_GRAPH_FILTER_GAUSS, 16, 1000); DDDraw.DrawCenter(DDPictureLoaders2.Wrapper(this.GraphScreen), 500, 500); DDSubScreenUtils.RestoreDrawScreen(); }
public void Draw(double[] spectra) { if (spectra.Length != 90) { throw null; // souteigai !!! } if (this.ShadowSpectra == null) { this.ShadowSpectra = new ShadowSpectraData(); } this.ShadowSpectra.Projection(spectra); DDSubScreenUtils.ChangeDrawScreen(this.GraphScreen); DX.ClearDrawScreen(); for (int c = 0; c < 10; c++) { double v = this.ShadowSpectra.ShadowSpectra[c * 9 + 0] + this.ShadowSpectra.ShadowSpectra[c * 9 + 1] + this.ShadowSpectra.ShadowSpectra[c * 9 + 2] + this.ShadowSpectra.ShadowSpectra[c * 9 + 3] + this.ShadowSpectra.ShadowSpectra[c * 9 + 4] + this.ShadowSpectra.ShadowSpectra[c * 9 + 5] + this.ShadowSpectra.ShadowSpectra[c * 9 + 6] + this.ShadowSpectra.ShadowSpectra[c * 9 + 7] + this.ShadowSpectra.ShadowSpectra[c * 9 + 8]; v /= 9.0; v *= 10.0; int iv = DoubleTools.ToInt(v); for (int d = 0; d < iv; d++) { int x1 = (c + 0) * 160; int x2 = (c + 1) * 160; int y1 = (d + 0) * 40; int y2 = (d + 1) * 40; x1 += 5; x2 -= 5; y1 += 3; y2 -= 3; DDDraw.SetBright(0.6, 0.4, 0.4); DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, x1, y1, x2 - x1, y2 - y1); DDDraw.Reset(); } } for (int c = 0; c < 10; c++) { double v = spectra[c * 9 + 0] + spectra[c * 9 + 1] + spectra[c * 9 + 2] + spectra[c * 9 + 3] + spectra[c * 9 + 4] + spectra[c * 9 + 5] + spectra[c * 9 + 6] + spectra[c * 9 + 7] + spectra[c * 9 + 8]; v /= 9.0; v *= 10.0; int iv = DoubleTools.ToInt(v); for (int d = 0; d < iv; d++) { int x1 = (c + 0) * 160; int x2 = (c + 1) * 160; int y1 = (d + 0) * 40; int y2 = (d + 1) * 40; x1 += 5; x2 -= 5; y1 += 3; y2 -= 3; DDDraw.SetBright(1.0, 0.8, 0.8); DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, x1, y1, x2 - x1, y2 - y1); DDDraw.Reset(); } } DDSubScreenUtils.ChangeDrawScreen(this.Screen); DX.ClearDrawScreen(); DDDraw.DrawBegin(DDPictureLoaders2.Wrapper(this.GraphScreen), this.Screen.GetSize().W / 2, this.Screen.GetSize().H / 2); DDDraw.SetBright(0, 0, 0); DDDraw.DrawEnd(); DDDraw.Reset(); DX.GraphFilter(this.Screen.GetHandle(), DX.DX_GRAPH_FILTER_GAUSS, 16, 1000); DDDraw.DrawCenter(DDPictureLoaders2.Wrapper(this.GraphScreen), this.Screen.GetSize().W / 2, this.Screen.GetSize().H / 2); DDSubScreenUtils.RestoreDrawScreen(); }
public void Draw(double[] spectra) { if (spectra.Length != SP_LEN) { throw null; // souteigai !!! } if (this.ShadowSpectra == null) { this.ShadowSpectra = new ShadowSpectraData(); } this.ShadowSpectra.Projection(spectra); DDSubScreenUtils.ChangeDrawScreen(this.GraphScreen); DX.ClearDrawScreen(); for (int layer = 0; layer < 2; layer++) { for (int bi = 0; bi < this.BarNum; bi++) { int c1 = (SP_LEN * (bi + 0)) / this.BarNum; int c2 = (SP_LEN * (bi + 1)) / this.BarNum; double v = 0.0; for (int c = c1; c < c2; c++) { v += (layer == 0 ? this.ShadowSpectra.ShadowSpectra : spectra)[c]; } v /= c2 - c1; int x1 = ((this.GraphScreen.GetSize().W - this.Bar_W) * bi) / (this.BarNum - 1); int x2 = x1 + this.Bar_W; int y1 = (int)((1.0 - v) * this.GraphScreen.GetSize().H); int y2 = this.GraphScreen.GetSize().H; if (y1 + 1 < y2) { double bright = layer == 0 ? 0.5 : 1.0; DDDraw.SetBright( bright * (this.BarColor.R / 255.0), bright * (this.BarColor.G / 255.0), bright * (this.BarColor.B / 255.0) ); DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, x1, y1, x2 - x1, y2 - y1); DDDraw.Reset(); } } } DDSubScreenUtils.ChangeDrawScreen(this.Screen); DX.ClearDrawScreen(); for (int c = 0; c < 2; c++) { DDDraw.DrawBegin(this.GraphScreen.ToPicture(), this.Screen.GetSize().W / 2, this.Screen.GetSize().H / 2); DDDraw.SetBright(0, 0, 0); DDDraw.DrawEnd(); DDDraw.Reset(); DX.GraphFilter(this.Screen.GetHandle(), DX.DX_GRAPH_FILTER_GAUSS, 16, 1000); } DDDraw.DrawCenter(this.GraphScreen.ToPicture(), this.Screen.GetSize().W / 2, this.Screen.GetSize().H / 2); DDSubScreenUtils.RestoreDrawScreen(); }
public void Draw(double[] spectra) { if (spectra.Length != 90) { throw null; // souteigai !!! } if (this.ShadowSpectra == null) { this.ShadowSpectra = new ShadowSpectraData(); } this.ShadowSpectra.Projection(spectra); DDSubScreenUtils.ChangeDrawScreen(this.GraphScreen); DX.ClearDrawScreen(); for (int c = 0; c < 10; c++) { double v = this.ShadowSpectra.ShadowSpectra[c * 9 + 0] + this.ShadowSpectra.ShadowSpectra[c * 9 + 1] + this.ShadowSpectra.ShadowSpectra[c * 9 + 2] + this.ShadowSpectra.ShadowSpectra[c * 9 + 3] + this.ShadowSpectra.ShadowSpectra[c * 9 + 4] + this.ShadowSpectra.ShadowSpectra[c * 9 + 5] + this.ShadowSpectra.ShadowSpectra[c * 9 + 6] + this.ShadowSpectra.ShadowSpectra[c * 9 + 7] + this.ShadowSpectra.ShadowSpectra[c * 9 + 8]; v /= 9.0; int x1 = c * 100; int x2 = x1 + 10; int y1 = (int)((1.0 - v) * this.GraphScreen.GetSize().H); int y2 = this.GraphScreen.GetSize().H; if (y1 + 1 < y2) { DDDraw.SetBright(0.4, 0.5, 0.6); DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, x1, y1, x2 - x1, y2 - y1); DDDraw.Reset(); } } for (int c = 0; c < 10; c++) { double v = spectra[c * 9 + 0] + spectra[c * 9 + 1] + spectra[c * 9 + 2] + spectra[c * 9 + 3] + spectra[c * 9 + 4] + spectra[c * 9 + 5] + spectra[c * 9 + 6] + spectra[c * 9 + 7] + spectra[c * 9 + 8]; v /= 9.0; int x1 = c * 100; int x2 = x1 + 10; int y1 = (int)((1.0 - v) * this.GraphScreen.GetSize().H); int y2 = this.GraphScreen.GetSize().H; if (y1 + 1 < y2) { DDDraw.DrawRect(DDGround.GeneralResource.WhiteBox, x1, y1, x2 - x1, y2 - y1); } } DDSubScreenUtils.ChangeDrawScreen(this.Screen); DX.ClearDrawScreen(); for (int c = 0; c < 2; c++) { DDDraw.DrawBegin(this.GraphScreen.ToPicture(), this.Screen.GetSize().W / 2, this.Screen.GetSize().H / 2); DDDraw.SetBright(0, 0, 0); DDDraw.DrawEnd(); DDDraw.Reset(); DX.GraphFilter(this.Screen.GetHandle(), DX.DX_GRAPH_FILTER_GAUSS, 16, 1000); } DDDraw.DrawCenter(this.GraphScreen.ToPicture(), this.Screen.GetSize().W / 2, this.Screen.GetSize().H / 2); DDSubScreenUtils.RestoreDrawScreen(); }