Colours to hue degree
hi there, i want to be able to convert the colours to hue degrees, there is java script available online that will do this but i have no programming experience!!, can you help, I've posted the java script code below:
Here is the java example to get the Hue:
public int getHue(int red, int green, int blue) {
float min = Math.min(Math.min(red, green), blue);
float max = Math.max(Math.max(red, green), blue);
float hue = 0f;
if (max == red) {
hue = (green - blue) / (max - min);
} else if (max == green) {
hue = 2f + (blue - red) / (max - min);
} else {
hue = 4f + (red - green) / (max - min);
}
hue = hue * 60;
if (hue < 0) hue = hue + 360;
return Math.round(hue);
}
hope you can help??
thanks Barry
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
Support Staff 1 Posted by hendrik on 14 Feb, 2015 07:28 PM
To better answer your question:
What do you want to do with the hue, once you have it?
2 Posted by Barry on 16 Feb, 2015 01:03 PM
Hi Hendrik
Thanks for your reply.
Once I have the hue degree I can assign a hue degree to a "beatunes coloured track".
I use Serato DJ where I can mark the tracks by 18 different colours (360 hue degrees divided by 18).
I've done some test mixing of tracks using your colours and it works great but I'm trying to simplify your RGB colours down to 18 different colours of a colour wheel (I'm aware that this will drastically decrease the accuracy of the your colours).
I'm having trouble converting the RGB number (255:255:255 etc) to a hue degree of a colour wheel and i'm trying to automate it using a plugin for your program but as i said before i have no programming skills.
When I'm djing it's to hard to switch from 2 programs to find a suitable track to play next so if they where coloured in Serato I can easily find the next one.
I hope that all makes sense!
thanks Barry
Support Staff 3 Posted by hendrik on 16 Feb, 2015 02:33 PM
Hey Barry,
first of all, beaTunes does not support JavaScript in any way.
You can write plugins in Java and the scripting languages like JRuby, Groovy, and JPython. But not in JavaScript.
In Java you can easily get the hue by calling:
HSB
stands for Hue, Saturation, Brightness.The resulting float array contains the hue as first value, i.e.
hsb[0]
.So to get the hue of a Java song, you'd write something like:
Hope this helps,
-hendrik
4 Posted by Barry on 17 Feb, 2015 05:45 PM
Hi Hendrik
thanks for your help, you've given me a start, I feel some Java tutorials coming on!!
will get beck to you if I'm able to sort out a plugin.
thanks again Barry :)
5 Posted by Barry on 17 Feb, 2015 05:56 PM
Yeah, I've just had a look at Marvin etc and I'm not going to be able to do this thanks anyway, Barry
Support Staff 6 Posted by hendrik on 18 Feb, 2015 09:30 AM
Actually, for beaTlets (https://www.beatunes.com/en/beatlet-getting-started.html) you don't need Maven at all...
But what I was wondering, how can you color your tracks in Serato DJ? What's the API there?
7 Posted by Barry on 18 Feb, 2015 07:30 PM
Hi Hendrik
Great I'll have a go at using beaTlets and your code, thank you!!
I'm not to sure what API is so I googled it and if I understand correctly it means that you could write your own code to use in the progam like a plugin.
I'm sure that Serato doesn't let you build your own plugin's but to colour a track all you do is click on a box next to the track screen shot 1.
Once you have done this when you load the track it appears like screen shot 2.
I plan to number each track with a degree then 1-20 degrees = red, 21-40 degrees = orange, 41-60 = yellow etc. To colour the tracks in Serato Dj is the easy bit.
This will let me quickly select the next track without having to scroll through menus etc whilst playing live.
Thanks Barry
Support Staff 8 Posted by hendrik on 18 Feb, 2015 08:03 PM
I'm not sure I understand... Why is coloring the tracks in Serato the easy bit? Sounds like a lot of manual work to me.
Also, once you have the hue for a given color, what do you want to do with it? Display it somewhere? Write it to the comment field? Something completely different?
If you just want to get the hue value out of beaTunes, try hovering with the mouse over a color value and it will give you the hue on a scale from 0 to 255 as the first value of hub in the tooltip.
9 Posted by Barry on 18 Feb, 2015 08:48 PM
Once I have the hue I'm going to write it to the "track number field". Then use the colour wheel (attached) to colour the tracks in Serato.
Using your tip about hovering the mouse over the colour (hsb) value means that I wouldn't have to convert anything!
Although I will have to manually copy the hue value across to the track number field, a bit of manual work but no big problem.
To colour the track's in Serato all i need to do is click on the tracks for values from 1-14 (red section on colour wheel) and colour them red, this can be done for all red tracks at once.
Then repeat for the other hue colours on the wheel i.e. 15-28 (orange section on wheel) e.tc.
thanks for the tip you've just saved me hours :)
10 Posted by Barry on 18 Feb, 2015 08:49 PM
sorry forgot to attach pic
Support Staff 11 Posted by hendrik on 24 Feb, 2015 10:10 AM
Hey Barry,
So does that mean, you're all set?
Cheers,
-hendrik
12 Posted by Barry on 24 Feb, 2015 06:29 PM
Hi Hendrik
Yes I've coloured all my tracks etc and am now djing with coloured tracks in Serato.
Thanks again for your help!!
Barry :)
hendrik closed this discussion on 25 Sep, 2015 11:03 AM.