虫虫首页| 资源下载| 资源专辑| 精品软件
登录| 注册

num<b>Be</b>rs

  • 单片机音乐中音调和节拍的确定方法

    单片机音乐中音调和节拍的确定方法:调号-音乐上指用以确定乐曲主音高度的符号。很明显一个八度就有12个半音。A、B、C、D、E、F、G。经过声学家的研究,全世界都用这些字母来表示固定的音高。比如,A这个音,标准的音高为每秒钟振动440周。 升C调:1=#C,也就是降D调:1=BD;277(频率)升D调:1=#D,也就是降E调:1=BE;311升F调:1=#F,也就是降G调:1=BG;369升G调:1=#G,也就是降A调:1=BA;415升A调:1=#A,也就是降B调:1=BB。466,C 262   #C277   D 294   #D(bE)311  E 330   F 349   #F369   G 392  #G415A 440.    #A466    B 494 所谓1=A,就是说,这首歌曲的“导”要唱得同A一样高,人们也把这首歌曲叫做A调歌曲,或叫“唱A调”。1=C,就是说,这首歌曲的“导”要唱得同C一样高,或者说“这歌曲唱C调”。同样是“导”,不同的调唱起来的高低是不一样的。各调的对应的标准频率为: 单片机演奏音乐时音调和节拍的确定方法 经常看到一些刚学单片机的朋友对单片机演奏音乐比较有兴趣,本人也曾是这样。在此,本人将就这方面的知识做一些简介,但愿能对单片机演奏音乐比较有兴趣而又不知其解的朋友能有所启迪。 一般说来,单片机演奏音乐基本都是单音频率,它不包含相应幅度的谐波频率,也就是说不能象电子琴那样能奏出多种音色的声音。因此单片机奏乐只需弄清楚两个概念即可,也就是“音调”和“节拍”。音调表示一个音符唱多高的频率,节拍表示一个音符唱多长的时间。 在音乐中所谓“音调”,其实就是我们常说的“音高”。在音乐中常把中央C上方的A音定为标准音高,其频率f=440Hz。当两个声音信号的频率相差一倍时,也即f2=2f1时,则称f2比f1高一个倍频程, 在音乐中1(do)与 ,2(来)与 ……正好相差一个倍频程,在音乐学中称它相差一个八度音。在一个八度音内,有12个半音。以1—i八音区为例, 12个半音是:1—#1、#1—2、2—#2、#2—3、3—4、4—#4,#4—5、5一#5、#5—6、6—#6、#6—7、7—i。这12个音阶的分度基本上是以对数关系来划分的。如果我们只要知道了这十二个音符的音高,也就是其基本音调的频率,我们就可根据倍频程的关系得到其他音符基本音调的频率。 知道了一个音符的频率后,怎样让单片机发出相应频率的声音呢?一般说来,常采用的方法就是通过单片机的定时器定时中断,将单片机上对应蜂鸣器的I/O口来回取反,或者说来回清零,置位,从而让蜂鸣器发出声音,为了让单片机发出不同频率的声音,我们只需将定时器予置不同的定时值就可实现。那么怎样确定一个频率所对应的定时器的定时值呢?以标准音高A为例:   A的频率f = 440 Hz,其对应的周期为:T = 1/ f = 1/440 =2272μs 由上图可知,单片机上对应蜂鸣器的I/O口来回取反的时间应为:t = T/2 = 2272/2 = 1136μs这个时间t也就是单片机上定时器应有的中断触发时间。一般情况下,单片机奏乐时,其定时器为工作方式1,它以振荡器的十二分频信号为计数脉冲。设振荡器频率为f0,则定时器的予置初值由下式来确定:    t = 12 *(TALL – THL)/ f0 式中TALL = 216 = 65536,THL为定时器待确定的计数初值。因此定时器的高低计数器的初值为:     TH = THL / 256 = ( TALL – t* f0/12) / 256    TL = THL % 256 = ( TALL – t* f0/12) %256  将t=1136μs代入上面两式(注意:计算时应将时间和频率的单位换算一致),即可求出标准音高A在单片机晶振频率f0=12Mhz,定时器在工作方式1下的定时器高低计数器的予置初值为 :    TH440Hz = (65536 – 1136 * 12/12) /256 = FBH    TL440Hz = (65536 – 1136 * 12/12)%256 = 90H根据上面的求解方法,我们就可求出其他音调相应的计数器的予置初值。 音符的节拍我们可以举例来说明。在一张乐谱中,我们经常会看到这样的表达式,如1=C  、1=G …… 等等,这里1=C,1=G表示乐谱的曲调,和我们前面所谈的音调有很大的关联, 、 就是用来表示节拍的。以 为例加以说明,它表示乐谱中以四分音符为节拍,每一小结有三拍。比如:      其中1 、2 为一拍,3、4、5为一拍,6为一拍共三拍。1 、2的时长为四分音符的一半,即为八分音符长,3、4的时长为八分音符的一半,即为十六分音符长,5的时长为四分音符的一半,即为八分音符长,6的时长为四分音符长。那么一拍到底该唱多长呢?一般说来,如果乐曲没有特殊说明,一拍的时长大约为400—500ms 。我们以一拍的时长为400ms为例,则当以四分音符为节拍时,四分音符的时长就为400ms,八分音符的时长就为200ms,十六分音符的时长就为100ms。可见,在单片机上控制一个音符唱多长可采用循环延时的方法来实现。首先,我们确定一个基本时长的延时程序,比如说以十六分音符的时长为基本延时时间,那么,对于一个音符,如果它为十六分音符,则只需调用一次延时程序,如果它为八分音符,则只需调用二次延时程序,如果它为四分音符,则只需调用四次延时程序,依次类推。通过上面关于一个音符音调和节拍的确定方法,我们就可以在单片机上实现演奏音乐了。具体的实现方法为:将乐谱中的每个音符的音调及节拍变换成相应的音调参数和节拍参数,将他们做成数据表格,存放在存储器中,通过程序取出一个音符的相关参数,播放该音符,该音符唱完后,接着取出下一个音符的相关参数……,如此直到播放完毕最后一个音符,根据需要也可循环不停地播放整个乐曲。另外,对于乐曲中的休止符,一般将其音调参数设为FFH,FFH,其节拍参数与其他音符的节拍参数确定方法一致,乐曲结束用节拍参数为00H来表示。下面给出部分音符(三个八度音)的频率以及以单片机晶振频率f0=12Mhz,定时器在工作方式1下的定时器高低计数器的予置初值 : C调音符  频率Hz 262 277 293 311 329 349 370 392 415 440 466 494TH/TL F88B F8F2 F95B F9B7 FA14 FA66 FAB9 FB03 FB4A FB8F FBCF FC0BC调音符 1 1# 2 2# 3 4 4# 5 5# 6 6# 7频率Hz 523 553 586 621 658 697 739 783 830 879 931 987TH/TL FC43 FC78 FCAB FCDB FD08 FD33 FD5B FD81 FDA5 FDC7 FDE7 FE05C调音符  频率Hz 1045 1106 1171 1241 1316 1393 1476 1563 1658 1755 1860 1971TH/TL FB21 FE3C FE55 FE6D FE84 FE99 FEAD FEC0 FE02 FEE3 FEF3 FF02

    标签: 单片机 音调

    上传时间: 2013-10-20

    上传用户:哈哈haha

  • Input Signal Rise and Fall Tim

    All inputs of the C16x family have Schmitt-Trigger input characteristics. These Schmitt-Triggers are intended to always provide proper internal low and high levels, even if anundefined voltage level (between TTL-VIL and TTL-VIH) is externally applied to the pin.The hysteresis of these inputs, however, is very small, and can not be properly used in anapplication to suppress signal noise, and to shape slow rising/falling input transitions.Thus, it must be taken care that rising/falling input signals pass the undefined area of theTTL-specification between VIL and VIH with a sufficient rise/fall time, as generally usualand specified for TTL components (e.g. 74LS series: gates 1V/us, clock inputs 20V/us).The effect of the implemented Schmitt-Trigger is that even if the input signal remains inthe undefined area, well defined low/high levels are generated internally. Note that allinput signals are evaluated at specific sample points (depending on the input and theperipheral function connected to it), at that signal transitions are detected if twoconsecutive samples show different levels. Thus, only the current level of an input signalat these sample points is relevant, that means, the necessary rise/fall times of the inputsignal is only dependant on the sample rate, that is the distance in time between twoconsecutive evaluation time points. If an input signal, for instance, is sampled throughsoftware every 10us, it is irrelevant, which input level would be seen between thesamples. Thus, it would be allowable for the signal to take 10us to pass through theundefined area. Due to the sample rate of 10us, it is assured that only one sample canoccur while the signal is within the undefined area, and no incorrect transition will bedetected. For inputs which are connected to a peripheral function, e.g. capture inputs, thesample rate is determined by the clock cycle of the peripheral unit. In the case of theCAPCOM unit this means a sample rate of 400ns @ 20MHz CPU clock. This requiresinput signals to pass through the undefined area within these 400ns in order to avoidmultiple capture events.For input signals, which do not provide the required rise/fall times, external circuitry mustbe used to shape the signal transitions.In the attached diagram, the effect of the sample rate is shown. The numbers 1 to 5 in thediagram represent possible sample points. Waveform a) shows the result if the inputsignal transition time through the undefined TTL-level area is less than the time distancebetween the sample points (sampling at 1, 2, 3, and 4). Waveform b) can be the result ifthe sampling is performed more than once within the undefined area (sampling at 1, 2, 5,3, and 4).Sample points:1. Evaluation of the signal clearly results in a low level2. Either a low or a high level can be sampled here. If low is sampled, no transition willbe detected. If the sample results in a high level, a transition is detected, and anappropriate action (e.g. capture) might take place.3. Evaluation here clearly results in a high level. If the previous sample 2) had alreadydetected a high, there is no change. If the previous sample 2) showed a low, atransition from low to high is detected now.

    标签: Signal Input Fall Rise

    上传时间: 2013-10-23

    上传用户:copu

  • 微机接口技术试题

    微机接口技术试题:《微机接口技术》模拟试题  一、 选择题:(每空1分,共20分)1. CPU与外设之间交换数据常采用        、       、       和        四种方式,PC机键盘接口采用      传送方式。 ⒉ 当进行DMA方式下的写操作时,数据是从       传送到       __中。 ⒊ PC总线、ISA总线和EISA总线的地址线分别为:     、     和     根。 ⒋ 8254定时/计数器内部有     个端口、共有     种工作方式。 ⒌8255的A1和A0引脚分别连接在地址总线的A1和A0,当命令端口的口地址为317H时,则A口、B口、C口的口地址分别为     、     、      。 ⒍ PC微机中最大的中断号是       、最小的中断号是       。 ⒎PC微机中键盘是从8255的       口得到按键数据。 ⒏ 串行通信中传输线上即传输_________,又传输_________。 二、选择题:(每题2分,共10分)⒈ 设串行异步通信每帧数据格式有8个数据位、无校验、一个停止位,若波特率为9600B/S,该方式每秒最多能传送(    )个字符。  ①  1200     ②  150 ③  960          ④  120 2.输出指令在I/O接口总线上产生正确的命令顺序是(    )。① 先发地址码,再发读命令,最后读数据。② 先发读命令、再发地址码,最后读数据。③ 先送地址码,再送数据,最后发写命令。④ 先送地址码,再发写命令、最后送数据。3 使用8254设计定时器,当输入频率为1MHZ并输出频率为100HZ时,该定时器的计数初值为(      )。 ① 100   ② 1000 ③ 10000 ④ 其它 4 在PC机中5号中断,它的中断向地址是(     )。 ① 0000H:0005H   ② 0000H:0010H ③ 0000H:0014H        ④ 0000H:0020H 5. 四片8259级联时可提供的中断请求总数为(      )。 ① 29个  ② 30个  ③ 31个    ④ 32个 6. 下述总线中,组内都是外设串行总线为(   )组。① RS-485、IDE、ISA。② RS-485、IEEE1394、USB。③ RS-485、PCI、IEEE1394。④ USB、SCSI、RS-232。 7. DMA在(  )接管总线的控制权。① 申请阶段  ② 响应阶段 ③ 数据传送阶段   ④ 结束阶段 8. 中断服务程序入口地址是(  )。 ① 中断向量表的指针 ② 中断向量 ③ 中断向量表  ④ 中断号

    标签: 微机 接口技术 试题

    上传时间: 2013-11-16

    上传用户:xiaoxiang

  • 电子电路百科全书

    该电路集包括了从业界享有盛名的公司搜集到的大量最新电路,体现了丰富的设计思想。为便于读者理解和应用这些电路,本书几乎对每个电路都附有简要说明。$ C' I" t% P5 l3 V. l0 K, B 本书可供电子技术工作者、高等院校和中等专科学校师生、电子爱好者阅读和参考。( H& s, \, z6 ~% D: @

    标签: 电子电路 百科

    上传时间: 2013-10-19

    上传用户:songnanhua

  • WHAT MIME64 IS: MIME64 is an encoding described in RFC1341 as MIME base64.Its purpose is to encode b

    WHAT MIME64 IS: MIME64 is an encoding described in RFC1341 as MIME base64.Its purpose is to encode binary files into ASCII so that they may be passedthrough e-mail gates. In this regard, MIME64 is similar to UUENCODE.Although most binaries these days are transmitted using UUENCODE, Ihave seen a few using MIME64, and I have had requests from friends thatI decode MIME64 files that have fallen into their hands. As long assome MIME64 continues to exist, a package such as this one is usefulto have.

    标签: MIME described 64 encoding

    上传时间: 2013-12-17

    上传用户:maizezhen

  • mp3设计程序资料

    mp3设计程序资料,采用c语言编写。 README file for yampp-3 source code 2001-05-27 This is the current state of the yampp-3 source code, 2001-05-27. This code is intended to run on Rev. B of the yampp-3 PCB, but can ofcourse be used on compatible systems as well. It still uses the "old" song selection system as the yampp-2. However, the disk handling routines has improved a lot and the obviosly, the new VS1001 handling has been put in. The codesize is almost at it s maximum at 1F40 bytes. A .ROM file is included if you don t have the compiler set up. For now, the documentation is in the code

    标签: mp3 设计程序

    上传时间: 2015-04-13

    上传用户:小码农lz

  • prolog 找路例子程序: === === === === === === Part 1-Adding connections Part 2-Simple Path example

    prolog 找路例子程序: === === === === === === Part 1-Adding connections Part 2-Simple Path example | ?- path1(a,b,P,T). will produce the response: T = 15 P = [a,b] ? Part 3 - Non-repeating path As an example, the query: ?- path2(a,h,P,T). will succeed and may produce the bindings: P = [a,depot,b,d,e,f,h] T = 155 Part 4 - Generating a path below a cost threshold As an example, the query: ?- path_below_cost(a,[a,b,c,d,e,f,g,h],RS,300). returns: RS = [a,b,depot,c,d,e,g,f,h] ? RS = [a,c,depot,b,d,e,g,f,h] ? no ==================================

    标签: Part connections example prolog

    上传时间: 2015-04-24

    上传用户:ljt101007

  • Rotating shafts experience a an elliptical motion called whirl. It is important to decompose this mo

    Rotating shafts experience a an elliptical motion called whirl. It is important to decompose this motion into a forward and backward whil orbits. The current function makes use of two sensors to generate a bi-directional spectrogram. The method can be extended to any time-frequency distribution % % compute the forward/backward Campbell/specgtrogram % % INPUT: % y (n x 2) each column is measured from a different sensor % /////// % __ % |s1| y(:,1) % |__| % __ % / \ ________|/ % | | | s2 |/ y(:,2) % \____/ --------|/ % % Fs Sampling frequnecy % % OUTPUT: % B spectrogram/Campbel diagram % x x-axis coordinate vector (time or Speed) % y y-axis coordinate vector (frequency [Hz])

    标签: experience elliptical decompose important

    上传时间: 2015-06-23

    上传用户:372825274

  • Implemented BFS, DFS and A* To compile this project, use the following command: g++ -o search ma

    Implemented BFS, DFS and A* To compile this project, use the following command: g++ -o search main.cpp Then you can run it: ./search The input is loaded from a input file in.txt Here is the format of the input file: The first line of the input file shoud contain two chars indicate the source and destination city for breadth first and depth first algorithm. The second line of input file shoud be an integer m indicate the number of connections for the map. Following m lines describe the map, each line represents to one connection in this form: dist city1 city2, which means there is a connection between city1 and city2 with the distance dist. The following input are for A* The following line contains two chars indicate the source and destination city for A* algorithm. Then there is an integer h indicate the number of heuristic. The following h lines is in the form: city dist which means the straight-line distance from the city to B is dist.

    标签: Implemented following compile command

    上传时间: 2014-01-01

    上传用户:lhc9102

  • acm HDOJ 1051WoodenSticks Description: There is a pile of n wooden sticks. The length and weight o

    acm HDOJ 1051WoodenSticks Description: There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs some time, called setup time, for the machine to prepare processing a stick. The setup times are associated with cleaning operations and changing tools and shapes in the machine. The setup times of the woodworking machine are given as follows: (a) The setup time for the first wooden stick is 1 minute. (b) Right after processing a stick of length l and weight w , the machine will need no setup time for a stick of length l and weight w if l<=l and w<=w . Otherwise, it will need 1 minute for setup.

    标签: WoodenSticks Description length wooden

    上传时间: 2014-03-08

    上传用户:netwolf