目前,遇到一个需求,需要按照仿真计算出来的噪声频谱还有噪声强度控制扬声器播放出对应的声音。没有音频文件,声音是动态算出来的,而且需要控制声音的大小,所以BEEP函数也不行。
2条回答 默认 最新
- StjpStjp 2021-08-25 18:46关注
点击旁边的采纳
我发你我曾经做过的代码:
我是用Beep的
运行正常#include <cstdio> #include <windows.h> #define qdo 262 #define qri 294 #define qmi 330 //q前缀为低音,1后缀为高音 #define qfa 349 #define qso 392 #define qla 440 #define qxi 494 #define doo 523 #define ri 578 #define mi 659 #define fa 698 #define so 784 #define la 880 #define xi 988 #define do1 1046 #define ri1 1175 #define mi1 1318 #define fa1 1480 #define so1 1568 #define la1 1760 #define xi1 1976 #define do11 2092 #define ri11 2350 #define mi11 2636 #define fa11 2960 #define so11 3136 #define la11 3560 #define xi11 3952 int main() { int pai=400,ban=200; int ting=128; Beep(ri1,pai); Beep(mi1,ban); Beep(do1,ban); Beep(ri1,pai*3); Beep(mi1,pai); Beep(fa1,pai); Beep(so1,pai); Beep(mi1,pai); Beep(do1,pai); Beep(ri1,pai); Beep(mi1,ban); Beep(do1,ban); Beep(ri1,pai*3); Sleep(ting); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(fa,ban>>1); Beep(so,ban>>1); Beep(la,ban); Beep(so,ban); Beep(fa,ban>>1); Beep(mi,ban>>1); Beep(ri,pai*2); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(fa,ban>>1); Beep(so,ban>>1); Beep(la,ban); Beep(so,ban); Beep(fa,ban>>1); Beep(mi,ban>>1); Beep(ri,pai*3);// Beep(qla,pai); Beep(ri,pai*3); Beep(mi,ban); Beep(fa,ban); Beep(so,pai*2); Beep(la,ban>>1); Beep(so,ban>>1); Beep(fa,ban>>1); Beep(mi,ban>>1); Beep(ri,ban>>1); Beep(doo,ban>>1); Beep(ri,pai*2); Beep(qla,pai*4); Beep(qso,pai); Beep(ri,pai*3); Beep(mi,ban); Beep(fa,ban); Beep(so,pai*2); Beep(la,ban>>1); Beep(so,ban>>1); Beep(fa,ban>>1); Beep(mi,ban>>1); Beep(ri,ban>>1); Beep(doo,ban>>1); Beep(ri,pai*2); Beep(la,pai*2); Beep(so,pai*2); Beep(do1,pai*2); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(fa,ban>>1); Beep(so,ban>>1); Beep(la,ban); Beep(so,ban); Beep(fa,ban>>1); Beep(mi,ban>>1); Beep(ri,pai*3); Beep(qla,pai); Beep(ri,pai*3); Beep(mi,ban); Beep(fa,ban); Beep(so,pai*2); Beep(la,ban>>1); Beep(so,ban>>1); Beep(fa,ban>>1); Beep(mi,ban>>1); Beep(ri,ban>>1); Beep(doo,ban>>1); Beep(ri,pai*2); Beep(qla,pai*4); Beep(qso,pai); Beep(ri,pai*3); Beep(mi,ban); Beep(fa,ban); Beep(so,pai*2); Beep(la,ban>>1); Beep(so,ban>>1); Beep(fa,ban>>1); Beep(mi,ban>>1); Beep(ri,ban>>1); Beep(doo,ban>>1); Beep(ri,pai*2); Beep(la,pai*2); Beep(so,pai*2); Beep(do1,pai*2); Beep(ri1,pai*3); Beep(mi1,ban); Beep(fa1,ban); Beep(so1,pai*2); Beep(la1,ban>>1); Beep(so1,ban>>1); Beep(fa1,ban>>1); Beep(mi1,ban>>1); Beep(ri1,ban>>1); Beep(do1,ban>>1); Beep(ri1,pai*2); Beep(la,pai*4); Beep(so,pai); Beep(ri,pai*3); Beep(mi,ban); Beep(fa,ban); Beep(so,pai*2); Beep(la,ban>>1); Beep(so,ban>>1); Beep(fa,ban>>1); Beep(mi,ban>>1); Beep(ri,ban>>1); Beep(doo,ban>>1); Beep(ri,pai*2); Beep(la,pai*2); Beep(so,pai*2); Beep(do1,pai*2); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(ri1,ban); Beep(ri1,ban); Beep(ri,ban); Beep(ri1,ban); Beep(do1,ban); Beep(xi,ban>>1); Beep(la,ban>>1); Beep(xi,ban); Beep(la,ban>>1); Beep(so,ban>>1); Beep(ri1,pai); Beep(ri1,pai*6); return 0; }
解决 无用评论 打赏 举报
悬赏问题
- ¥15 想问一下STM32创建工程模板时遇到得问题
- ¥15 Fiddler抓包443
- ¥20 Qt Quick Android 项目报错及显示问题
- ¥15 而且都没有 OpenCVConfig.cmake文件我是不是需要安装opencv,如何解决?
- ¥15 oracleBIEE analytics
- ¥15 H.264选择性加密例程
- ¥50 windows的SFTP服务器如何能批量同步用户信息?
- ¥15 centos7.9升级python3.0的问题
- ¥15 安装CentOS6时卡住
- ¥20 c语言写的8051单片机存储器mt29的模块程序