写入简谱(flash钢琴谱)自动播放简谱琴声程序 c#
发布时间:2020-12-15 17:21:58 所属栏目:百科 来源:网络整理
导读:这个音乐程序,有个缺点,就是节拍不好控制,你不懂要输入多少个空格(表示延时多少)?读简谱时钟的时钟周期是多少? /* 甩葱歌简谱 测试用 QTTUVTTTVUSSSUTT TTQTTUVTTTOQQQPOUVTT XXWVUSSSUWWWWVUOTT TTXXWVUSSSUWWWWVUVTT */ using System; using System
这个音乐程序,有个缺点,就是节拍不好控制,你不懂要输入多少个空格(表示延时多少)?读简谱时钟的时钟周期是多少? /* 甩葱歌简谱 测试用 QTTUVTTTVUSSSUTT TTQTTUVTTTOQQQPOUVTT XXWVUSSSUWWWWVUOTT TTXXWVUSSSUWWWWVUVTT */ using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace gangqinzidongbofang { ? ? public partial class Form1 : Form ? ? { ? ? ? ? public Form1() ? ? ? ? { ? ? ? ? ? ? InitializeComponent(); ? ? ? ? } ? ? ? ? public static uint SND_ASYNC = 0x0001; // ? ? ? ? public static uint SND_FILENAME = 0x00020000; ? ? ? ? [DllImport("winmm.dll")] ? ? ? ? public static extern uint mciSendString(string lpstrCommand,? ? ? ? string lpstrReturnString,uint uReturnLength,uint hWndCallback); ? ? ? ? string path = @"D:DownloadSilverlightkeycodefans.net键盘钢琴AphroditePianoSound"; ? ? ? ? string keyname = ""; ? ? ? ? string stryinjie = ""; ? ? ? ? int i; ? ? ? ?? ? ? ? ? private void button1_Click(object sender,EventArgs e) ? ? ? ? { ? ? ? ? ? ? ?stryinjie = richTextBox1.Text; ? ? ? ? ? ? ?i = 0; ? ? ? ? ? ? ?timer1.Interval = 200; ? ? ? ? ? ? ?timer1.Enabled = true; ? ? ? ? } ? ? ? ? private void timer1_Tick(object sender,EventArgs e) ? ? ? ? { ? ? ? ? ? ? if (char.IsLetter(stryinjie[i])) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? //D:DownloadSilverlightkeycodefans.net键盘钢琴AphroditePianoSound目录,保存了A.mp3 ?B.mp3 ?C.mp3到Z.mp3,分别存放了不同的音阶MP3文件 ? ? ? ? ? ? ? ? string keyname = char.ToUpper(stryinjie[i]) + ".mp3"; ? ? ? ? ? ? ? ? string alldir = path + keyname; ? ? ? ? ? ? ? ? mciSendString(@"close temp_alias",null,0); ? ? ? ? ? ? ? ? mciSendString(@"open " + alldir + " alias temp_alias",0); ? ? ? ? ? ? ? ? //("play temp_alias repeat",0); ? ? ? ? ? ? ? ? mciSendString("play temp_alias ",0); ? ? ? ? ? ? } ? ? ? ? ? ? else ? ? ? ? ? ? { ? ? ? ? ? ? ? ? if (stryinjie[i].Equals(' '))//等于空格 ? ? ? ? ? ? ? ? { ? ? ? ? ? ? ? ? ? ? System.Threading.Thread.Sleep(2000); ? ? ? ? ? ? ? ? ? ? //if(Delay(1)); ? ? ? ? ? ? ? ? ? ? ? ?? ? ? ? ? ? ? ? ? } ? ? ? ? ? ? } ? ? ? ? ? ? i++; ? ? ? ? ? ? if (i == stryinjie.Length) ? ? ? ? ? ? { ? ? ? ? ? ? ? ? timer1.Enabled = false; ? ? ? ? ? ? } ? ? ? ? } ? ? ? ? /// <summary> ? ? ? ? /// 延时函数 ? ? ? ? /// </summary> ? ? ? ? /// <param name="delayTime">需要延时多少秒</param> ? ? ? ? /// <returns></returns> ? ? ? ? public static bool Delay(int delayTime) ? ? ? ? { ? ? ? ? ? ? DateTime now = DateTime.Now; ? ? ? ? ? ? int s; ? ? ? ? ? ? do ? ? ? ? ? ? { ? ? ? ? ? ? ? ? TimeSpan spand = DateTime.Now - now; ? ? ? ? ? ? ? ? s = spand.Seconds; ? ? ? ? ? ? ? ? Application.DoEvents(); ? ? ? ? ? ? } ? ? ? ? ? ? while (s < delayTime); ? ? ? ? ? ? return true; ? ? ? ? } ? ? } }(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |