Skip to content
This repository
Browse code

SoundFile:cue : add closeWhenDone option

  • Loading branch information...
commit 142f9960406f0fc32a70297dc7d5149d93a82768 1 parent dcc8b11
Iannis Zannos iani authored timblechmann committed

Showing 1 changed file with 12 additions and 8 deletions. Show diff stats Hide diff stats

  1. +12 8 SCClassLibrary/Common/Files/SoundFile.sc
20 SCClassLibrary/Common/Files/SoundFile.sc
@@ -413,8 +413,8 @@ SoundFile {
413 413 ^buffer
414 414 }
415 415
416   - cue { | ev, playNow = false |
417   - var server, packet, defname = "diskIn" ++ numChannels, condition;
  416 + cue { | ev, playNow = false, closeWhenDone = false |
  417 + var server, packet, defname = "diskIn" ++ numChannels, condition, onClose;
418 418 ev = ev ? ();
419 419 if (this.numFrames == 0) { this.info };
420 420 fork {
@@ -442,13 +442,10 @@ SoundFile {
442 442 ["/b_free", ev[\bufnum] ] )
443 443 };
444 444 ~setwatchers = { |ev|
445   - OSCpathResponder(server.addr, ["/n_end", ev[\id][0]],
446   - { | time, resp, msg |
  445 + OSCFunc({
447 446 server.sendBundle(server.latency, ["/b_close", ev[\bufnum]],
448   - ["/b_read", ev[\bufnum], path, ev[\firstFrame], ev[\bufferSize], 0, 1]);
449   - resp.remove;
450   - }
451   - ).add;
  447 + ["/b_read", ev[\bufnum], path, ev[\firstFrame], ev[\bufferSize], 0, 1]);
  448 + }, "/n_end", server.addr, nil, ev[\id][0]).oneShot;
452 449 };
453 450 if (playNow) {
454 451 packet = server.makeBundle(false, {ev.play})[0];
@@ -462,6 +459,13 @@ SoundFile {
462 459 ]);
463 460 };
464 461 };
  462 + if (closeWhenDone) {
  463 + onClose = SimpleController(ev).put(\n_end, {
  464 + ev.close;
  465 + onClose.remove;
  466 + });
  467 + ev.addDependant(onClose)
  468 + };
465 469 ^ev;
466 470 }
467 471

0 comments on commit 142f996

Please sign in to comment.
Something went wrong with that request. Please try again.