全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3015 15
2019-10-09
%let pc=0.75;/*调节曲速,越小越快*/
%macro df3(note,octave,length);
   select(&note);
      when("A") call sound(55*(2**&octave.),&length.*160*&pc.);
      when("A#") call sound(58*(2**&octave.),&length.*160*&pc.);
      when("Bb") call sound(58*(2**&octave.),&length.*160*&pc.);
      when("B") call sound(62*(2**&octave.),&length.*160*&pc.);
      when("C") call sound(65*(2**&octave.),&length.*160*&pc.);
      when("C#") call sound(69*(2**&octave.),&length.*160*&pc.);
      when("Db") call sound(69*(2**&octave.),&length.*160*&pc.);
      when("D") call sound(73.5*(2**&octave.),&length.*160*&pc.);
      when("D#") call sound(73.5*(2**&octave.),&length.*160*&pc.);
      when("Eb") call sound(78*(2**&octave.),&length.*160*&pc.);
      when("E") call sound(82*(2**&octave.),&length.*160*&pc.);
      when("F") call sound(87*(2**&octave.),&length.*160*&pc.);
      when("F#") call sound(92.5*(2**&octave.),&length.*160*&pc.);
      when("Gb") call sound(92.5*(2**&octave.),&length.*160*&pc.);
      when("G") call sound(98*(2**&octave.),&length.*160*&pc.);
      when("G#") call sound(104*(2**&octave.),&length.*160*&pc.);
      when("Ab") call sound(104*(2**&octave.),&length.*160*&pc.);
      when("R") call sleep((&length./3)*&pc.,1);
      otherwise;
   end;
%mend;

/*创建简谱*/
data jianpu;
   input x $ @@;/*输入简谱,半拍为单位,-为下面加点,+为上面加点,可以加多个点*/
   note=translate(compress(x,,'kd'),'CDEFGABR','12345670');
   octave=3;
   octave=octave+(note in ('A','B'))+count(compress(x,,'d'),'+')-count(compress(x,,'d'),'-');
cards;
5 6 5 4 3 2 1 1 1 5- 5- 5- 1 3 1+ 7 6 3 5 5 5 5 5 5
6 7 6 5 4 3 2 2 2 6- 6- 6- 7- 6- 5- 5 1 2 3 3 3 3 3 3
5 6 5 4 3 2 1 1 1 5- 5- 5- 1 3 1+ 7 2+ 1+ 6 6 6 6 6 6
1+ 7 6 5 5 5 6 5 4 3 3 3 7- 6- 5- 2 2 2 1 1 1 1 1 1
1+ 2+ 3+ 2+ 1+ 6 7 6 3 5 5 5 5 5 5 1+ 2+ 3+ 2+ 1+ 6
7 5 3 6 6 6 6 6 6 5 4 3 2 2 2 7- 6- 5- 3 3 3 4 4 4 2 2 1 1 1 1 1 1 0
1+ 2+ 3+ 2+ 1+ 6 7 6 3 5 5 5 1+ 2+ 3+ 2+ 1+ 6 7 5 3 6 6 6
5 4 3 2 2 2 7 6 5 3 3 3 5 5 5 2+ 2+ 1+ 1+ 1+ 1+ 1+ 1+ 1+
;
run;

/*创建宏变量&note.和&octave.用于存储简谱中所有的note和对应的octave*/
proc sql noprint;
   select note, octave into : note separated by '*', : octave separated by '*'
   from jianpu;
quit;

/*播放*/
proc printto log=_null_;run;
%macro music;
data want;
   call execute('data _null_;');
   %do i=1 %to %sysfunc(countw(&note,'*'));
      %df3("%scan(&note,&i,'*')",%scan(&octave,&i,'*'),1);
   %end;
   call execute('run;');
run;
%mend;
%music
proc printto log=log;run;

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2019-10-9 17:24:37
大佬就是有才
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2019-10-9 19:57:37
l1i2n3i4n5g 发表于 2019-10-9 11:23
%let pc=0.75;/*调节曲速,越小越快*/
%macro df3(note,octave,length);
   select(&note);
这个不错!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2019-10-10 22:25:59
李宁你是个鬼才
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2019-10-14 12:59:49
太厉害了,可以转载么?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2019-10-15 08:07:07
医念之间 发表于 2019-10-14 12:59
太厉害了,可以转载么?
可以呀
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群