键盘小钢琴[C语言][自制]

大一上最喜欢的一个作品 大笑。刚开始只是一个能自动发出小星星音乐的小程序XD

效果图:


代码如下:

/*This is a small piano.这是一个小钢琴哦~*/
#include<stdio.h>
#include<conio.h>    //非缓冲输入
#include<stdlib.h>
#include<Windows.h>
#pragma warning(disable:4996)  //to use getche() in VS needs it
#define TICK 450
#define DOH 523
#define RAY 587
#define MI 659
#define FA  698
#define SOH  784
#define LA   880
#define TEE   980
#define DOHH  1060
#define RAYH  1175
#define MIH   1318
#define FAH  1397
#define SOHH  1568
#define LAH   1760
#define TEEH  1976

void welcome(void);
void displa
  • 7
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
%频谱分析 clear all close all y0=mscale(3,1,20000,60,'钢琴'); % 音调中音C,钢琴,1秒音乐(四分音符,速度60) ,采样率20000 [y1,Fs,nbits]=wavread('吉他音节.wav'); [y2,Fs,nbits]=wavread('钢琴音节.wav'); [y3,Fs,nbits]=wavread('小提琴音节.wav'); [y4,Fs,nbits]=wavread('萨克斯音节.wav');   x0=y0; f0=fft(x0);           n1=Fs; % 取1秒数据 x1=y1(1:n1);f1=fft(x1); x2=y2(1:n1);f2=fft(x2); x3=y3(1:n1);f3=fft(x3); x4=y4(1:n1);f4=fft(x4); figure(1); subplot(1,4,1);plot(x1);title('吉他单音节波形(1sec)'); subplot(1,4,2);plot(x2);title('钢琴单音节波形(1sec)'); subplot(1,4,3);plot(x3);title('小提琴单音节波 形(1sec)'); subplot(1,4,4);plot(x4);title('萨克斯单音节波 形(1sec)');           figure(2); subplot(4,1,1);plot(abs(f1)); title('低音C-吉他单音节频谱(采样率44100)'); subplot(4,1,2);plot(abs(f2)); title('低音C-钢琴单音节频谱(采样率44100)'); subplot(4,1,3);plot(abs(f3)); title('中音C-小提琴单音节频谱(采样率44100)'); subplot(4,1,4);plot(abs(f4)); title('低音C-萨克斯单音节频谱(采样率44100)'); n2=1000;   figure(3); subplot(4,1,1);plot(abs(f1(1:n2)));               title('低音C-吉他单音节频谱(0-1000Hz)'); subplot(4,1,2);plot(abs(f2(1:n2))); title('低音C-钢琴单音节频谱(0-1000Hz)'); subplot(4,1,3);plot(abs(f3(1:n2))); title('中音C-小提琴单音节频谱(0-1000Hz)'); subplot(4,1,4);plot(abs(f0(1:n2))); title('中音C-自制钢琴单音节频谱(0-1000Hz)'); figure(4); subplot(3,1,1);plot(y4(1:n1*2)); title('萨克斯单音节波形(2sec)'); subplot(3,1,2);plot(y2(1:n1*2)); title('钢琴单音节波形(2sec)'); subplot(3,1,3);plot(y0); title('自制钢琴单音节波形(1sec)');
06-06

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值