音乐播放器的制作
摘要
作为单片机的重要硬件资源之一,利用定时器可以产生各种固定频率的方波信号,也可以产生包括“Do“、“Re“、“Me“--等音阶在内的各种频率声音。在此设计中我们采用12MHz的晶振,,信号经过放大后由喇叭发出声音。
乐曲中,每一音符对应着确定的频率,我们可以参照给出的各音符频率及其相应的时间常数来编写程序,根据表中所提供的常数,将其16进制代码送入芯片里,可以奏出音符。音符的节拍我们可以用定时器T0来控制,送入不同的初值,就可以产生不同的定时时间。便如某歌曲的节奏为每分钟94拍,。其它节拍与时间的对应关系也可以从两者关系表中得到。
定时器T0工作在定时方式1,改变TH0及TL0,产生不同的音频频率。要编写的乐谱按要求以音符字节数据表的形式存放在程序中,改变乐曲就是通过改变该数据表的内容来实现的。主程序的任务是按顺序读取数据表中的字节,根据情况调用音级子程序和音长子程序,启动定时器T0进行工作。
关键词: 音乐播放器、节拍、音频频率
Abstract
SCM as important resources of the hardware, using the timer could have a variety of fixed-frequency square-wave signal,and also could have included "Do", "Re" and "Me" -- such as scale, the frequency sound ,In this design, we used 12 MHz oscillator, the frequency signal that the music signal output from mouth, After signal amplified by the loudspeaker to make their voices heard.
Music, each note corresponds to determine the frequency, We can refer to the notes given to the frequency and time constant corresponding to the preparation to the table provided by the constant, 16 to 229 of its code into the chip, and then the music can be celebrate the rhythms T0 timer can be used to control and to different initial value, it can have different timing exaple,some songs to the rhythm of each 94-minute film, a film of seconds. Other rhythms and the time relationship can also relations between the two tables.
Timer T0 work in a regular manner, cytokines and TL0 change, the different audio frequencies. To prepare the scores required to note byte data table in the form of stored procedures, change is the music of the data by changing the content to achieve main program is a sequential read data byte table, according to the sound level of the subroutine call and audio eldest son procedures, start timer T0 work.
Keywords:music player, beats, audio frequency
一、方案选择
利用AT89C2051和芯片LM386构成的音乐播放器
利用AT89C2051和芯片LM386构成的音乐播放器的电路图比较简单,而且LM386的放大和滤波效
基于AT89S51单片机酒精浓度探测仪的设计与实现 来自淘豆网www.taodocs.com转载请标明出处.