Javadocs and KeyToGrouping

Rico's Avatar

Rico

09 Nov, 2011 04:19 PM

Hi, I downloaded your javadocs and the source for the KeyToGrouping plugin. It's great work, thank you very much, other developers could learn from you. However I still can't find the info I need - more my fault that yours I'm sure.

I want to edit the plugin so that it adds the contents of the tuning tag after the key. Can you point me in the right direction please?

Thank you.

  1. Support Staff 1 Posted by hendrik on 09 Nov, 2011 04:29 PM

    hendrik's Avatar

    Hey Rico,

    com.tagtraum.audiokern.AudioSong has a method Integer getTuning(), which will deliver the tuning in cents (if available).

    To get the tuning in Hz, do something like this:

    Integer tuning = song.getTuning();
    if (tuning != null && tuning > 0) {
        float hertz = 440 * Math.pow(2, tuning/1200f));
        // ...
    }
    

    Does that answer your question?

    -hendrik

  2. 2 Posted by Rico on 09 Nov, 2011 05:26 PM

    Rico's Avatar

    Thanks for the snappy response.

    Am I right in thinking that this function generates the string that goes into the grouping tag:

    private String addGroupingKey(final String grouping, final Key key) {
        return grouping + KEY_START_MARKER + key.getTKey() + KEY_END_MARKER;
    }
    

    If so how would I add the tuning (in cents please) after the KEY_END_MARKER

    Thanks again.

  3. Support Staff 3 Posted by hendrik on 09 Nov, 2011 05:37 PM

    hendrik's Avatar

    That function adds the key string to the existing grouping string. In order to easily replace the key string during updates, the key string is surrounded by two marker strings.

    If you want to add the cents, they would also need to go in between the KEY_START_MARKER and the KEY_END_MARKER.

    -hendrik

  4. 4 Posted by Rico on 09 Nov, 2011 05:41 PM

    Rico's Avatar

    OK, so could I do something like this:

    private String addGroupingKey(final String grouping, final Key key) {
        return grouping + KEY_START_MARKER + key.getTKey() +  DIVIDER + song.getTuning() + KEY_END_MARKER;
    }
    

    Where DIVIDER would be previously declared as, say, a colon.

    Thanks again.

  5. Support Staff 5 Posted by hendrik on 09 Nov, 2011 05:44 PM

    hendrik's Avatar

    Yep, that should work..

    Note though, that song is not in scope - you need to call song.getTuning() where addGroupingKey(...) is called and pass the results (i.e. the tuning) as a parameter.

  6. 6 Posted by Rico on 09 Nov, 2011 05:53 PM

    Rico's Avatar

    So I would call with this line:

            grouping = addGroupingKey(grouping, song.getSongAnnotation().getKey(), song.getTuning());
    

    and edit the addGroupingKey function as follows:

    private String addGroupingKey(final String grouping, final Key key, final Integer tuning) {
        return grouping + KEY_START_MARKER + key.getTKey() + DIVIDER + tuning + KEY_END_MARKER;
    }
    

    Thanks for your patience - I'm new to Java

  7. Support Staff 7 Posted by hendrik on 09 Nov, 2011 05:56 PM

    hendrik's Avatar

    That looks about right.
    I can only recommend to use an IDE, like e.g. http://www.jetbrains.com/idea/ Community Edition.

    -hendrik

  8. 8 Posted by Rico on 09 Nov, 2011 07:06 PM

    Rico's Avatar

    Thanks for the advice - will do.

    A secondary question: what method or variable is the round coloured key indicator derived from please?

  9. hendrik closed this discussion on 25 Sep, 2015 11:07 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac