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

A-Moving-Object-<b>DATABASE</b>-Model-Ba

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

    单片机音乐中音调和节拍的确定方法:调号-音乐上指用以确定乐曲主音高度的符号。很明显一个八度就有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

  • 源代码用动态规划算法计算序列关系个数 用关系"<"和"="将3个数a

    源代码\用动态规划算法计算序列关系个数 用关系"<"和"="将3个数a,b,c依次序排列时,有13种不同的序列关系: a=b=c,a=b<c,a<b=v,a<b<c,a<c<b a=c<b,b<a=c,b<a<c,b<c<a,b=c<a c<a=b,c<a<b,c<b<a 若要将n个数依序列,设计一个动态规划算法,计算出有多少种不同的序列关系, 要求算法只占用O(n),只耗时O(n*n).

    标签: lt 源代码 动态规划 序列

    上传时间: 2013-12-26

    上传用户:siguazgb

  • The government of a small but important country has decided that the alphabet needs to be streamline

    The government of a small but important country has decided that the alphabet needs to be streamlined and reordered. Uppercase letters will be eliminated. They will issue a royal decree in the form of a String of B and A characters. The first character in the decree specifies whether a must come ( B )Before b in the new alphabet or ( A )After b . The second character determines the relative placement of b and c , etc. So, for example, "BAA" means that a must come Before b , b must come After c , and c must come After d . Any letters beyond these requirements are to be excluded, so if the decree specifies k comparisons then the new alphabet will contain the first k+1 lowercase letters of the current alphabet. Create a class Alphabet that contains the method choices that takes the decree as input and returns the number of possible new alphabets that conform to the decree. If more than 1,000,000,000 are possible, return -1. Definition

    标签: government streamline important alphabet

    上传时间: 2015-06-09

    上传用户:weixiao99

  • 交通信号灯的控制: 1. 通过8255A并口来控制LED发光二极管的亮灭。 2. A口控制红灯

    交通信号灯的控制: 1. 通过8255A并口来控制LED发光二极管的亮灭。 2. A口控制红灯,B口控制黄灯,C口控制绿灯。 3. 输出为0则亮,输出为1则灭。 4. 用8253定时来控制变换时间 。 要求:设有一个十字路口,1、3为南,北方向,2、4为东西方向,初始态为4个路口的红灯全亮。之后,1、3路口的绿灯亮,2、4路口的红灯亮,1、3路口方向通车。延迟30秒后,1、3路口的绿灯熄灭,而1,3路口的黄灯开始闪烁(1HZ)。闪烁5次后,1、3路口的红灯亮,同时2、4路口的绿灯亮,2、4路口方向开始通车。延迟30秒时间后,2、4路口的绿灯熄灭,而黄灯开始闪烁。闪烁5次后,再切换到1、3路口方向。之后,重复上述过程。

    标签: 8255A 控制 LED 交通信号灯

    上传时间: 2014-01-03

    上传用户:zhouli

  • A one-dimensional calibration object consists of three or more collinear points with known relative

    A one-dimensional calibration object consists of three or more collinear points with known relative positions. It is generally believed that a camera can be calibrated only when a 1D calibration object is in planar motion or rotates around a ¯ xed point. In this paper, it is proved that when a multi-camera is observing a 1D object undergoing general rigid motions synchronously, the camera set can be linearly calibrated. A linear algorithm for the camera set calibration is proposed,and then the linear estimation is further re¯ ned using the maximum likelihood criteria. The simulated and real image experiments show that the proposed algorithm is valid and robust.

    标签: one-dimensional calibration collinear consists

    上传时间: 2014-01-12

    上传用户:璇珠官人

  • We have a group of N items (represented by integers from 1 to N), and we know that there is some tot

    We have a group of N items (represented by integers from 1 to N), and we know that there is some total order defined for these items. You may assume that no two elements will be equal (for all a, b: a<b or b<a). However, it is expensive to compare two items. Your task is to make a number of comparisons, and then output the sorted order. The cost of determining if a < b is given by the bth integer of element a of costs (space delimited), which is the same as the ath integer of element b. Naturally, you will be judged on the total cost of the comparisons you make before outputting the sorted order. If your order is incorrect, you will receive a 0. Otherwise, your score will be opt/cost, where opt is the best cost anyone has achieved and cost is the total cost of the comparisons you make (so your score for a test case will be between 0 and 1). Your score for the problem will simply be the sum of your scores for the individual test cases.

    标签: represented integers group items

    上传时间: 2016-01-17

    上传用户:jeffery

  • 1) Write a function reverse(A) which takes a matrix A of arbitrary dimensions as input and returns a

    1) Write a function reverse(A) which takes a matrix A of arbitrary dimensions as input and returns a matrix B consisting of the columns of A in reverse order. Thus for example, if A = 1 2 3 then B = 3 2 1 4 5 6 6 5 4 7 8 9 9 8 7 Write a main program to call reverse(A) for the matrix A = magic(5). Print to the screen both A and reverse(A). 2) Write a program which accepts an input k from the keyboard, and which prints out the smallest fibonacci number that is at least as large as k. The program should also print out its position in the fibonacci sequence. Here is a sample of input and output: Enter k>0: 100 144 is the smallest fibonacci number greater than or equal to 100. It is the 12th fibonacci number.

    标签: dimensions arbitrary function reverse

    上传时间: 2016-04-16

    上传用户:waitingfy

  • The LM628/LM629 are dedicated motion-control processors designed for use with a variety of DC and b

    The LM628/LM629 are dedicated motion-control processors designed for use with a variety of DC and brushless DC servo motors

    标签: motion-control processors dedicated designed

    上传时间: 2014-01-23

    上传用户:aa17807091

  • 1. 通过8255A并口来控制LED发光二极管的亮灭。 2. A口控制红灯

    1. 通过8255A并口来控制LED发光二极管的亮灭。 2. A口控制红灯,B口控制黄灯,C口控制绿灯。 3. 输出为0则亮,输出为1则灭。 4. 用8253定时来控制变换时间 。

    标签: 8255A LED 控制 并口

    上传时间: 2013-12-06

    上传用户:cccole0605

  • Visual tracking is one of the key components for robots to accomplish a given task in a dynamic env

    Visual tracking is one of the key components for robots to accomplish a given task in a dynamic environment, especially when independently moving objects are included. This paper proposes an extension of Adaptive Visual Servoing (hereafter, AVS) for unknown moving object tracking. The method utilizes binocular stereo vision, but does not need the knowledge of camera parameters. Only one assumption is that the system need stationary references in the both images by which the system can predict the motion of unknown moving objects. The basic ideas how we extended the AVS method such that it can track unknown moving objects are given and formalized into a new AVS system. The experimental results with proposed control architecture are shown and a discussion is given.

    标签: components accomplish tracking dynamic

    上传时间: 2013-12-11

    上传用户:lizhen9880