- /
-
Create Audio
on 10 Oct 2024
- 19
- 195
- 0
- 3
- 1294
Cite your audio source here (if applicable):
drawframe(1);
Write your drawframe function below
function drawframe(f)
persistent a b
if f == 96
createAudio();
end
if f == 1
createBackground();
a = plot(0, 0);
b = scatter(0, 0);
end
x = 3 + f * 4 / 30;
a.delete
a = plot([x x], [12 16], 'r-', 'LineWidth', 1);
x = 2 * ceil(f/12) - 1;
b.delete
b = scatter(x, 1.2, 900, 'b', 'filled');
end
function createAudio()
Fs = 44100;
duration = 0.49;
t = 0 : 1/Fs : duration;
frequencies = [
261.626 % C4 ド
293.665 % D4 レ
329.628 % E4 ミ
349.228 % F4 ファ
391.995 % G4 ソ
440.000 % A4 ラ
493.883 % B4 シ
523.251 % C4 ド
];
d = Fs * 0.01;
fade = linspace(1, 0, d);
sounds = [];
for fr = frequencies'
sound = 0.5 * sin(2 * pi * fr * t);
sound(1:d) = sound(1:d) .* flip(fade);
sound(end-d+1:end) = sound(end-d+1:end) .* fade;
sounds = [sounds, sound, zeros(1, d)];
end
audiowrite('audio.wav', repmat(sounds, 1, 3), Fs);
end
function createBackground()
set(gcf, 'Position', [0 0 600 600]);
hold on
axis off
xlim([0 16]);
ylim([0 16]);
plot([0 0], [13.5 15.5], 'k', 'LineWidth', 3);
plot([16 16], [13.5 15.5], 'k', 'LineWidth', 3);
for i = 0 : 4
yline(13.5+i/2, 'k', 'LineWidth', 1.5);
end
text(3, 14.85, '𝄞', 'FontSize', 85, 'FontName', 'Serif');
for i = 0:7
text(2.7+i*1.6, 14.25+i/4, '𝅝', 'FontSize', 60, 'FontName', 'Serif');
end
plot([2.6 3.8], [13 13], 'k', 'LineWidth', 1.5);
for i = 0:7
rectangle('Position', [2*i, 0, 2, 12], 'EdgeColor', 'k', 'FaceColor', 'w');
end
for v = [1.3 3.3 7.3 9.3 11.3]
rectangle('Position', [v, 4, 1.4, 8], 'EdgeColor', 'k', 'FaceColor', 'k');
end
end
Movie
Audio
This submission does not have audio.