tag:help.beatunes.com,2009-07-24:/discussions/plugin/10-javadocs-and-keytogroupingbeaTunes: Discussion 2015-09-25T11:07:41Ztag:help.beatunes.com,2009-07-24:Comment/112698272011-11-09T16:29:13Z2011-11-09T16:29:13ZJavadocs and KeyToGrouping<div><p>Hey Rico,</p>
<p><code>com.tagtraum.audiokern.AudioSong</code> has a method
<code>Integer getTuning()</code>, which will deliver the tuning in
cents (if available).</p>
<p>To get the tuning in Hz, do something like this:</p>
<pre>
<code>Integer tuning = song.getTuning();
if (tuning != null && tuning > 0) {
float hertz = 440 * Math.pow(2, tuning/1200f));
// ...
}</code>
</pre>
<p>Does that answer your question?</p>
<p>-hendrik</p></div>hendriktag:help.beatunes.com,2009-07-24:Comment/112698272011-11-09T17:26:22Z2011-11-09T17:26:23ZJavadocs and KeyToGrouping<div><p>Thanks for the snappy response.</p>
<p>Am I right in thinking that this function generates the string
that goes into the grouping tag:</p>
<pre>
<code>private String addGroupingKey(final String grouping, final Key key) {
return grouping + KEY_START_MARKER + key.getTKey() + KEY_END_MARKER;
}</code>
</pre>
<p>If so how would I add the tuning (in cents please) after the
KEY_END_MARKER</p>
<p>Thanks again.</p></div>Ricotag:help.beatunes.com,2009-07-24:Comment/112698272011-11-09T17:37:27Z2011-11-09T17:37:27ZJavadocs and KeyToGrouping<div><p>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.</p>
<p>If you want to add the cents, they would also need to go in
between the <code>KEY_START_MARKER</code> and the
<code>KEY_END_MARKER</code>.</p>
<p>-hendrik</p></div>hendriktag:help.beatunes.com,2009-07-24:Comment/112698272011-11-09T17:41:53Z2011-11-09T17:41:54ZJavadocs and KeyToGrouping<div><p>OK, so could I do something like this:</p>
<pre>
<code>private String addGroupingKey(final String grouping, final Key key) {
return grouping + KEY_START_MARKER + key.getTKey() + DIVIDER + song.getTuning() + KEY_END_MARKER;
}</code>
</pre>
<p>Where DIVIDER would be previously declared as, say, a colon.</p>
<p>Thanks again.</p></div>Ricotag:help.beatunes.com,2009-07-24:Comment/112698272011-11-09T17:44:48Z2011-11-09T17:44:48ZJavadocs and KeyToGrouping<div><p>Yep, that should work..</p>
<p>Note though, that <code>song</code> is not in scope - you need
to call <code>song.getTuning()</code> where
<code>addGroupingKey(...)</code> is called and pass the results
(i.e. the tuning) as a parameter.</p></div>hendriktag:help.beatunes.com,2009-07-24:Comment/112698272011-11-09T17:53:55Z2011-11-09T17:53:57ZJavadocs and KeyToGrouping<div><p>So I would call with this line:</p>
<pre>
<code> grouping = addGroupingKey(grouping, song.getSongAnnotation().getKey(), song.getTuning());</code>
</pre>
<p>and edit the addGroupingKey function as follows:</p>
<pre>
<code>private String addGroupingKey(final String grouping, final Key key, final Integer tuning) {
return grouping + KEY_START_MARKER + key.getTKey() + DIVIDER + tuning + KEY_END_MARKER;
}</code>
</pre>
<p>Thanks for your patience - I'm new to Java</p></div>Ricotag:help.beatunes.com,2009-07-24:Comment/112698272011-11-09T17:56:43Z2011-11-09T17:56:43ZJavadocs and KeyToGrouping<div><p>That looks about right.<br>
I can only recommend to use an IDE, like e.g. <a href=
"http://www.jetbrains.com/idea/">http://www.jetbrains.com/idea/</a>
Community Edition.</p>
<p>-hendrik</p></div>hendriktag:help.beatunes.com,2009-07-24:Comment/112698272011-11-09T19:06:56Z2011-11-09T19:06:56ZJavadocs and KeyToGrouping<div><p>Thanks for the advice - will do.</p>
<p>A secondary question: what method or variable is the round
coloured key indicator derived from please?</p></div>Rico