Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Editor: problem using string args #177

Closed
walterbender opened this issue Feb 21, 2022 · 0 comments · Fixed by #180
Closed

Editor: problem using string args #177

walterbender opened this issue Feb 21, 2022 · 0 comments · Fixed by #180
Labels
bug Something isn't working component-editor Related to the component "Editor"

Comments

@walterbender
Copy link
Member

I cannot seem to get a string arg to work the the editor. For example, in test-synth, I can use hertz (a number) but when I change the pitch param to string, I get a compile error.

export class ElementTestSynth extends ElementStatement {
    constructor() {
        super('test-synth', 'test synth', { pitch: ['number'], noteValue: ['number'] });
    }
    onVisit(params: { [key: string]: TData }): void {
        const now = Tone.now();
	const noteValue = params['noteValue'] as number;
	const offset = noteValueToSeconds(_state.notesPlayed);
	console.error("TEST SYNTH", params['pitch'], noteValue, now, offset);
        _defaultSynth.triggerAttackRelease(params['pitch'] as number, noteValue + "n", now + offset);
	_state.notesPlayed += 1/noteValue;
    }
}

test-synth pitch:220 noteValue:8
builds successfully

export class ElementTestSynth extends ElementStatement {
    constructor() {
        super('test-synth', 'test synth', { pitch: ['string'], noteValue: ['number'] });
    }
    onVisit(params: { [key: string]: TData }): void {
        const now = Tone.now();
	const noteValue = params['noteValue'] as number;
	const offset = noteValueToSeconds(_state.notesPlayed);
	console.error("TEST SYNTH", params['pitch'], noteValue, now, offset);
        _defaultSynth.triggerAttackRelease(params['pitch'] as string, noteValue + "n", now + offset);
	_state.notesPlayed += 1/noteValue;
    }
}

test-synth pitch:"c4" noteValue:8
build fails

@walterbender walterbender added the bug Something isn't working label Feb 21, 2022
@meganindya meganindya added the component-editor Related to the component "Editor" label Feb 21, 2022
@meganindya meganindya changed the title problem using string args in editor Editor: problem using string args Feb 21, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working component-editor Related to the component "Editor"
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants