Code Monkey home page Code Monkey logo

Comments (3)

telephon avatar telephon commented on June 14, 2024

This has nothing to do with \pset or NodeProxy, it is the Pbindf that crashes when you pass it an EventStreamPlayer instead of a Pattern:

(
Pbindf(Pbind(
	\dur, 0.125,
	\amp, Pseq(((0..10)/100).scramble, inf),
	\mygate, 1.0,
).play, 
\foo, 8
).play;
)

instead of

(
Pbindf(Pbind(
	\dur, 0.125,
	\amp, Pseq(((0..10)/100).scramble, inf),
	\mygate, 1.0,
), 
\foo, 8
).play;
)

So the above should be:

Ndef(\crash, {
	var sig = SinOsc.ar * Env.perc.ar(gate: \mygate.tr(1.0));
	Pan2.ar(sig, \pos.kr(0.0));
});

// this crashes not
Ndef(\crash)[2] = \pset -> Pbind(
	\dur, 0.125,
	\amp, Pseq(((0..10)/100).scramble, inf),
        \mygate, 1.0,
)

Of course it would be good to make the Pbindf more tolerant.

from supercollider.

telephon avatar telephon commented on June 14, 2024

I am testing with this reproducer:

// this is fine
Pbindf(Pbind(\dur, Pseq([0.125], 1)).play, \foo, 8).play;
// if it crashes, this crashes it (infinite loop)
Pbindf(Pbind(\dur, Pseq([0.125], inf)).play, \foo, 8).play;

What happens happens in EventStreamPlayer.prNext. First an error is thrown, then the interpreter crashes.

ERROR: Message 'round' not understood.
RECEIVER:
   nil
ARGS:

PROTECTED CALL STACK:
	Meta_MethodError:new	0x7fe5419a7d40
		arg this = DoesNotUnderstandError
		arg what = nil
		arg receiver = nil
	Meta_DoesNotUnderstandError:new	0x7fe5419b1dc0
		arg this = DoesNotUnderstandError
		arg receiver = nil
		arg selector = round
		arg args = []
	Object:doesNotUnderstand	0x7fe570284540
		arg this = nil
		arg selector = round
		arg args = nil
	EventStreamPlayer:prNext	0x7fe52074a440
		arg this = an EventStreamPlayer
		arg inTime = ()
		var nextTime = 0.125
		var outEvent = ('instrument': default, 'mygate': 1.0, 'dur': 0.125, 'amp': 0.04, 
  'server': localhost, 'sustain': 0.1, 'isPlaying': true, 'hasGate': true, 'id': [1001], 
  'msgFunc': a Function, 'freq': 261.6255653006)
		var roundedBeat = nil
		var deltaFromRounded = nil
	a FunctionDef	0x7fe520748280
		sourceCode = "<an open Function>"
	Function:prTry	0x7fe5205a4d80
		arg this = a Function
		var result = nil
		var thread = a Routine
		var next = nil
		var wasInProtectedFunc = false
	
CALL STACK:
	DoesNotUnderstandError:reportError
		arg this = <instance of DoesNotUnderstandError>
	Nil:handleError
		arg this = nil
		arg error = <instance of DoesNotUnderstandError>
	Thread:handleError
		arg this = <instance of Thread>
		arg error = <instance of DoesNotUnderstandError>
	Thread:handleError
		arg this = <instance of Routine>
		arg error = <instance of DoesNotUnderstandError>
	Object:throw
		arg this = <instance of DoesNotUnderstandError>
	Function:protect
		arg this = <instance of Function>
		arg handler = <instance of Function>
		var result = <instance of DoesNotUnderstandError>
	Routine:prStart
		arg this = <instance of Routine>
		arg inval = 9.9995203150029
^^ ERROR: Message 'round' not understood.
RECEIVER: nil


Interpreter has crashed or stopped forcefully. [Exit code: 11]

This happens because of the protect of the EventStreamPlayer, which should call streamError, if it is commented out, no crash happens.

init {
		cleanup = EventStreamCleanup.new;
		routine = Routine { |inTime|
			loop { inTime = this.prNext(inTime).yield }
			/*protect {
				loop { inTime = this.prNext(inTime).yield }
			} { |result|
				if(result.isException) {
					this.streamError
				}
			}*/
		};
	}

It is not the streamError, but in the protect:

this crashes:

init {
		cleanup = EventStreamCleanup.new;
		routine = Routine { |inTime|
			protect {
				loop { inTime = this.prNext(inTime).yield }
			} { |result|
				if(result.isException) {
				//	this.streamError
				}
			}
		};
	}

also this crashes:

init {
		cleanup = EventStreamCleanup.new;
		routine = Routine { |inTime|
			protect {
				loop { inTime = this.prNext(inTime).yield }
			}
		};
	}

So somehow, returning from a protected call is the problem here.

If don't return in prNext, it does not crash (just end):

prNext { arg inTime; // <----------------- inTime is an event
		var nextTime;
		var outEvent = stream.next(event.copy);
		var roundedBeat, deltaFromRounded;
		if (outEvent.isNil) {
			streamHasEnded = stream.notNil;
			cleanup.clear;
			this.removedFromScheduler;
			^nil
		} {
			nextTime = outEvent.playAndDelta(cleanup, muteCount > 0);
			if (nextTime.isNil) { this.removedFromScheduler; ^nil };
			nextBeat = inTime + nextTime;	// inval is current logical beat
			roundedBeat = nextBeat.round;  // <-------------------------------------- error happens here (Event.round)
			deltaFromRounded = roundedBeat - nextBeat;
			if (deltaFromRounded.smallButNotZero) {
				nextBeat = roundedBeat;
				nextTime = nextTime + deltaFromRounded;
			};

///			^nextTime // <------------------------- commented out
		};
	}

from supercollider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.