Song.ck 838 B

1234567891011121314151617181920212223242526272829303132
  1. public class Song
  2. {
  3. fun void playParts(SongPart parts[])
  4. {
  5. // <<< "setParts() nParts=" , parts.cap() >>> ;
  6. now => time begin ; now => time endTime ;
  7. for(0 => int partN ; partN < parts.cap() ; ++partN)
  8. {
  9. parts[partN] @=> SongPart part ; begin + part.runningTime => time partEndTime ;
  10. if (partEndTime > endTime) partEndTime => endTime ;
  11. spork ~ playPart(part , endTime) ;
  12. }
  13. play(endTime) ;
  14. }
  15. fun void playPart(SongPart part , time endTime)
  16. {
  17. // <<< "playPart() nNotes=" , part.notes.cap() >>> ;
  18. for(0 => int noteN ; noteN < part.notes.cap() ; ++noteN)
  19. {
  20. // <<< "playPart() noteN=" , noteN , " dur=" , part.durations[noteN] >>> ;
  21. part.playNote(noteN) => now ; part.stopNote(noteN) => now ;
  22. }
  23. endTime => now ;
  24. }
  25. fun void play(time endTime) { endTime => now ; }
  26. }