回答編集履歴

3

ラグの改良: 数値表示を周波数再生の後にする

2020/10/04 23:18

投稿

teamikl
teamikl

スコア8760

test CHANGED
@@ -26,13 +26,13 @@
26
26
 
27
27
  def on_forever():
28
28
 
29
- basic.show_number(num)
30
-
31
29
  if len(FREQ_LIST) > num >= 0:
32
30
 
33
31
  freq = FREQ_LIST[num]
34
32
 
35
33
  music.play_tone(freq, music.beat(BeatFraction.BREVE))
34
+
35
+ basic.show_number(num)
36
36
 
37
37
  basic.forever(on_forever)
38
38
 
@@ -92,13 +92,15 @@
92
92
 
93
93
  def play_note():
94
94
 
95
- basic.show_number(num)
96
-
97
95
  if len(FREQ_LIST) > num >= 0:
98
96
 
99
97
  freq = FREQ_LIST[num]
100
98
 
101
99
  music.play_tone(freq, music.beat(BeatFraction.BREVE))
100
+
101
+ basic.show_number(num)
102
+
103
+
102
104
 
103
105
 
104
106
 
@@ -108,7 +110,7 @@
108
110
 
109
111
  num += 1
110
112
 
111
- music.rest(1)
113
+ music.rest(0)
112
114
 
113
115
  control.in_background(play_note)
114
116
 

2

変数名変更。

2020/10/04 23:18

投稿

teamikl
teamikl

スコア8760

test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- freqs = [
11
+ FREQ_LIST = [
12
12
 
13
13
  294,
14
14
 
@@ -28,9 +28,11 @@
28
28
 
29
29
  basic.show_number(num)
30
30
 
31
- freq = freqs[num]
31
+ if len(FREQ_LIST) > num >= 0:
32
32
 
33
+ freq = FREQ_LIST[num]
34
+
33
- music.play_tone(freq, music.beat(BeatFraction.BREVE))
35
+ music.play_tone(freq, music.beat(BeatFraction.BREVE))
34
36
 
35
37
  basic.forever(on_forever)
36
38
 
@@ -72,7 +74,7 @@
72
74
 
73
75
 
74
76
 
75
- freqs = [
77
+ FREQ_LIST = [
76
78
 
77
79
  294,
78
80
 
@@ -92,9 +94,11 @@
92
94
 
93
95
  basic.show_number(num)
94
96
 
95
- freq = freqs[num]
97
+ if len(FREQ_LIST) > num >= 0:
96
98
 
99
+ freq = FREQ_LIST[num]
100
+
97
- music.play_tone(freq, music.beat(BeatFraction.BREVE))
101
+ music.play_tone(freq, music.beat(BeatFraction.BREVE))
98
102
 
99
103
 
100
104
 

1

エラー修正。但し、リストの半チェックが必要になります

2020/10/04 22:29

投稿

teamikl
teamikl

スコア8760

test CHANGED
@@ -28,11 +28,9 @@
28
28
 
29
29
  basic.show_number(num)
30
30
 
31
- if len(freq) > num >= 0:
31
+ freq = freqs[num]
32
32
 
33
- freq = freqs[num]
34
-
35
- music.play_tone(freq, music.beat(BeatFraction.BREVE))
33
+ music.play_tone(freq, music.beat(BeatFraction.BREVE))
36
34
 
37
35
  basic.forever(on_forever)
38
36
 
@@ -94,11 +92,9 @@
94
92
 
95
93
  basic.show_number(num)
96
94
 
97
- if len(freq) > num >= 0:
95
+ freq = freqs[num]
98
96
 
99
- freq = freqs[num]
100
-
101
- music.play_tone(freq, music.beat(BeatFraction.BREVE))
97
+ music.play_tone(freq, music.beat(BeatFraction.BREVE))
102
98
 
103
99
 
104
100