Scripting error

User avatar
Captain
Posts: 71
Joined: Sat Aug 25, 2018 11:12 am

Sun May 26, 2019 5:13 pm

Got your source code, thanks! To tell the truth, I'm a bit confused what you want the code to do :D Anyway, here are some pointers to help you get forward:

- Everything is case sensitive! From Java's point of view, "volumevalue" is a completely different thing than "volumeValue". It doesn't really matter which one you use, as long as you use it consistently everywhere. I also suggest reading about Java's naming conventions (how to name objects and methods etc). Those are only conventions, but help make your code more readable to other people, and probably yourself too.

- Read about objects and primitives, and what is their difference. In your code, "volumevalue" is declared a primitive (double), but elsewhere, you try to call a method called volumevalue.SetValue(), which does not work, since primitives don't have methods.

- Be careful what goes where in the module's source code. As you can see, when you start a new project in MD, there's already a bunch of code there, and you can only edit some specific spots in the code. Familiarize yourself with the structure of a new blank project, and the stuff that is already there: which methods get called at what times, etc. For example, the code you have placed inside the "GetTooltipText" method, I'm pretty sure it's not supposed to be there... Make sure you read the help text above the GetTooltipText method, it should give you an idea when that method is called. Also make sure you don't have any extra leftover code anywhere where there is not supposed to be any.

- Most of audio processing code will probably be inside the ProcessSample() method

- As I said earlier, using curly brackets with IF is always a good idea :) Like this:

Code: Select all

if ( test something here ) {
	do something here
	do something more
	still part of the IF block
}
after the IF block
Hope this helps at least a little bit! I warmly recommend reading some general Java tutorials and learning the basics of Java, before diving too deep into Module Designer. I guarantee things will be much easier that way. :) But on the other hand, you can get pretty far with just the basics!
JackOats
Posts: 58
Joined: Sun May 12, 2019 4:09 pm
Location: KENT, UK.

Mon May 27, 2019 9:15 am

Hi - Thanks very much for the message.
I'm a bit confused what you want the code to do
Well, as I said in my original post I'm trying to create a Volume Knob.

I'm just copying the code supplied in the example given by MD - it's not my scripting.

You can see the tutorial at: Help page/Voltage User Guide/Voltage Module Designer/Module Programming Example.
I warmly recommend reading some general Java tutorials and learning the basics of Java
Thanks. Yes, I am studying Java scripting at the moment. I'm following a set of very helpful videos at cosmo learning.org by

'thenewboston'.

Very interesting.

I'm going to go through the MD tutorial again, with a fine tooth comb! I must have gone wrong somewhere. :?

Thanks very much for all your tips. Really appreciate it.
iMac 27/Mojave/3.5 GBh Intel Core i7/16 GB Ram/3 TB HD
The masculine includes the feminine (Guys)
Google: 'JackOats' to see my Soundcloud page, 'Brian Watterson - Vimeo' for my Videos.
User avatar
Captain
Posts: 71
Joined: Sat Aug 25, 2018 11:12 am

Mon May 27, 2019 11:57 am

Yeah, the thing about programming is that you need to be very careful with syntax and other details. :D One wrong character somewhere might mean the whole thing won’t compile. You seem to have all the necessary stuff there already, just make sure the syntax is correct (lowercase vs uppercase, etc), every line of code is where it is supposed to be, and if-statements have the curly brackets... and I’m sure it will work. Good luck!

BTW, you could create the simplest possible volume knob module with just a single line of code :) Make sure you have one input jack, one ouput jack, and one knob in the GUI, and set their variable names to inputJack, outputJack, and volumeKnob (and check that the knob has a range 0-1). Then insert this inside the ProcessSample() function:

Code: Select all

outputJack.SetValue( inputJack.GetValue() * volumeKnob.GetValue() );
Very crude and could use a lot of improvements, but already does the job! (Disclaimer: I’m typing this on my phone, so there might be some typos etc.)
JackOats
Posts: 58
Joined: Sun May 12, 2019 4:09 pm
Location: KENT, UK.

Mon May 27, 2019 5:09 pm

Thank you.
insert this inside the ProcessSample() function:
CODE: SELECT ALL
outputJack.SetValue( inputJack.GetValue() * volumeKnob.GetValue() );

Tried this code but still get the same response I'm afraid:
java: 323: error: variable declaration not allowed here
Think I need to put in a request with the VM guys - I'm going crazy with this. :?

Thank you so much for taking the time & trouble - I'm really grateful for all your help. :)
iMac 27/Mojave/3.5 GBh Intel Core i7/16 GB Ram/3 TB HD
The masculine includes the feminine (Guys)
Google: 'JackOats' to see my Soundcloud page, 'Brian Watterson - Vimeo' for my Videos.
User avatar
Captain
Posts: 71
Joined: Sat Aug 25, 2018 11:12 am

Mon May 27, 2019 8:29 pm

JackOats wrote:
Mon May 27, 2019 5:09 pm
Tried this code but still get the same response I'm afraid:
java: 323: error: variable declaration not allowed here
Hmm, I’m pretty sure you accidentally left some extra code somewhere (on line 323, in fact)... make sure you start with a new clean project, just add the 3 GUI controls, then add this line of code (and make sure it’s inside ProcessSample()), and try again. Unfortunately I’m traveling without my computer for the whole week, so I can only try to debug things in my head...

And no problem, glad to help! :)
JackOats
Posts: 58
Joined: Sun May 12, 2019 4:09 pm
Location: KENT, UK.

Mon May 27, 2019 10:00 pm

Well, as I said, when I delete this line I get an error message that says it can't be "dereferenced".

Please don't waste any more time on this - I really don't want to bug you if your travelling around.

Watch this space! Something will develop I'm sure. :)

Thanks for being so generous with your time. It's really good of you.
iMac 27/Mojave/3.5 GBh Intel Core i7/16 GB Ram/3 TB HD
The masculine includes the feminine (Guys)
Google: 'JackOats' to see my Soundcloud page, 'Brian Watterson - Vimeo' for my Videos.
terrymcg
Posts: 23
Joined: Mon Apr 08, 2019 12:35 am

Mon May 27, 2019 11:23 pm

Hi Jack!

Maybe I'm old-fashioned (! ;) ) but it sounds to me like having a good Java *book* would be a big help in getting you going.

I don't have this one, but have been a fan of O'Reilly's "Animal" books for many (many) years so feel safe in suggesting it:
Learning Java, 4th Edition

(There are lots of others, that's just the first entry-level one I found on first site I searched - the O'Reilly site)

The Java version VM uses is a bit newer, but that's not going to matter to you for a while (if at all). There are some other complications to writing code in the VM environment that won't be covered either, but again, for the most part by the time you need to worry about it you'll be better equipped to do so.

Good luck!

Cheers,
--
Terry McG
JackOats
Posts: 58
Joined: Sun May 12, 2019 4:09 pm
Location: KENT, UK.

Tue May 28, 2019 8:04 am

Hi Terry,

Thanks for the message.
having a good Java *book* would be a big help in getting you going.
Absolutely! I am doing a video course online at the moment, but having a book to read as well would be a great help.

Just checked out the book you mention & it seems pretty comprehensive.

There's also a 10 day free trial reading - which I might go for first.

Thanks very much for the recommendation. :)
iMac 27/Mojave/3.5 GBh Intel Core i7/16 GB Ram/3 TB HD
The masculine includes the feminine (Guys)
Google: 'JackOats' to see my Soundcloud page, 'Brian Watterson - Vimeo' for my Videos.
JackOats
Posts: 58
Joined: Sun May 12, 2019 4:09 pm
Location: KENT, UK.

Thu May 30, 2019 9:20 pm

@terrymcg
@Captain
@CherryDan

Hi Guys - SOLVED!

One aspect of the problem, as you thought, was my rather mixed usage of capitalisation.

As you also spotted - a chunk of code in the Tool Tips section which shouldn't have been there. (Still not sure how it got there)!

There were mistakes too in the GUI design section concerning package file naming etc. which I think is still a problem area for me.

Anyway I got the project to compile today :D so thanks again Guys for all your help & a big thank you to Cherry Dan who very generously checked over my mod file & showed me (in double quick time) where I was going astray.

It's been a stressful few days but I've learned a lot & am extremely grateful for all the unselfish help given.

Very much appreciated Guys - Thank you so much. :)
iMac 27/Mojave/3.5 GBh Intel Core i7/16 GB Ram/3 TB HD
The masculine includes the feminine (Guys)
Google: 'JackOats' to see my Soundcloud page, 'Brian Watterson - Vimeo' for my Videos.
Post Reply