int conductor_beat = 0; void wait_for_beat(int current_beat); void release_beat(); // This is ABC notation; const char *Canon_in_D[4][8] = { {"D4", "A3", "B3", "F#3", "G3", "D3", "G3", "A3"}, // Below lines are generated by deepseek-r1 {"A3", "E3", "F#3", "C#3", "D3", "A2", "D3", "E3"}, {"F#3", "C#3", "D3", "A3", "B2", "F#2", "B2", "C#3"}, {"D3", "A2", "B2", "F#2", "G2", "D2", "G2", "A2"}, }; void T_player(int id) { for (int i = 0; i < LENGTH(Canon_in_D[0]); i++) { wait_for_beat(i); const char *note = Canon_in_D[id - 1][i]; // This is also UNIX philosophy: make everything // work together! char cmd[128]; sprintf(cmd, "ffplay -nodisp -autoexit" " -loglevel quiet" " notes/%s.wav" " > /dev/null &", note); // Should not use "system" like this // in production code. system(cmd); } } void T_conductor() { // This conductor is not full synchronized with the players. // You may make the system out of sync. char buf[32]; while (1) { printf("(conductor) > "); if (!fgets(buf, sizeof(buf), stdin)) { exit(0); } release_beat(); } } int main() { for (int i = 0; i < LENGTH(Canon_in_D); i++) { spawn(T_player); } spawn(T_conductor); }