Git Product home page Git Product logo

Comments (3)

terryzfeng avatar terryzfeng commented on July 17, 2024

I tried to recreate your example in miniAudicle and got a similar message. I believe static Bus @ bus[6] should instead be static Bus @ bus[]. Including the [6] means that the bus object will be instantiated rather than just being a null reference (or pointing to the already declared static reference).

// Test
class Mixer {
    0.5 => float volume;    
}

class Channel {
    static Mixer @ mix[]; // reference, [] vs [2]
}


Mixer mainMix;
Mixer mix2;

new Channel @=> Channel c1;
[mainMix, mix2] @=> c1.mix; // initialization outside of class

<<< "c1 mix", c1.mix >>>;

new Channel @=> Channel c2;

<<< "c2 mix", c2.mix >>>;

I got the same result in WebChucK IDE. Let me know if that helps!

from webchuck.

lmaxwell avatar lmaxwell commented on July 17, 2024

Sorry, I should have posted my original code here, https://github.com/lmaxwell/guiless-daw/blob/main/lib/mixer/Mixer.ck . The original code works ok with version 1.3.6.0.

I started from your example and tried the newest version of ChucK(1.4.2.0) , it did throw the same error if specifying a number for a static array inside class definition, while ChucK(1.3.6.0) did not throw any error. However, in 1.3.6.0 (if a number is given in class definition) Channel.mix(accessing from class name) points to the same instance, while c1.mix and c2.mix(accessing from instance) point to different instances. It seems a bug and 1.4.2 sovles this.

The following code works fine in both chuck(1.4.2.0) and webchuck IDE.

//a.ck
class Mixer {
    0.5 => float volume;    
}

public class Channel {
    static Mixer @ mix[]; // reference, [] vs [2]
}


Mixer mainMix;
Mixer mix2;

[mainMix, mix2] @=> Channel.mix; // initialization outside of class

new Channel @=> Channel c1;

<<< "a.ck:Channel.mix", Channel.mix >>>;
<<<"a.ck:c1.mix", c1.mix>>>;
//b.ck
new Channel @=> Channel c2;
<<<"b.ck:Channel.mix",Channel.mix>>>;
<<<"b.ck:c2.mix",c2.mix>>>;

Thank you for your help!

from webchuck.

terryzfeng avatar terryzfeng commented on July 17, 2024

No problem! Glad to see it working!

from webchuck.

Related Issues (13)

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.