better temp
This commit is contained in:
parent
b4c923408e
commit
b9249ed7af
@ -1,4 +1,5 @@
|
|||||||
#include "Voice.h"
|
#include "Voice.h"
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
void Voice::setup(Receiver &receiver)
|
void Voice::setup(Receiver &receiver)
|
||||||
{
|
{
|
||||||
@ -6,6 +7,11 @@ void Voice::setup(Receiver &receiver)
|
|||||||
_tex = gl::TextureFont::create(_font);
|
_tex = gl::TextureFont::create(_font);
|
||||||
_tex_name = gl::TextureFont::create(_font);
|
_tex_name = gl::TextureFont::create(_font);
|
||||||
|
|
||||||
|
std::ostringstream out;
|
||||||
|
out.precision(2);
|
||||||
|
out << std::fixed << _temperature;
|
||||||
|
_temperature_str = out.str();
|
||||||
|
|
||||||
/*- NET -*/
|
/*- NET -*/
|
||||||
receiver.setListener(_channel + "/utterance",
|
receiver.setListener(_channel + "/utterance",
|
||||||
[&](const osc::Message &m){
|
[&](const osc::Message &m){
|
||||||
@ -37,7 +43,13 @@ void Voice::setup(Receiver &receiver)
|
|||||||
[&](const osc::Message &m){
|
[&](const osc::Message &m){
|
||||||
std::lock_guard<std::mutex> lock(_temperatue_mutex);
|
std::lock_guard<std::mutex> lock(_temperatue_mutex);
|
||||||
float t = m[0].flt();
|
float t = m[0].flt();
|
||||||
if(_temperature != t) _temperature = t;
|
if(_temperature != t) {
|
||||||
|
_temperature = t;
|
||||||
|
std::ostringstream out;
|
||||||
|
out.precision(2);
|
||||||
|
out << std::fixed << _temperature;
|
||||||
|
_temperature_str = out.str();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -113,10 +125,7 @@ void Voice::update()
|
|||||||
void Voice::draw(Rectf &bounds, bool name, bool debug)
|
void Voice::draw(Rectf &bounds, bool name, bool debug)
|
||||||
{
|
{
|
||||||
// gl::color(_color);
|
// gl::color(_color);
|
||||||
if(name && debug) {
|
if(name && debug) _tex_name->drawStringWrapped(_name + " " + _temperature_str, bounds);
|
||||||
|
|
||||||
_tex_name->drawStringWrapped(_name + " " + std::to_string(_temperature), bounds);
|
|
||||||
}
|
|
||||||
else if(name) _tex_name->drawStringWrapped(_name, bounds);
|
else if(name) _tex_name->drawStringWrapped(_name, bounds);
|
||||||
_tex->drawStringWrapped(_utterance, bounds + _offset);
|
_tex->drawStringWrapped(_utterance, bounds + _offset);
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ using Receiver = osc::ReceiverUdp;
|
|||||||
/*- Voice -*/
|
/*- Voice -*/
|
||||||
class Voice {
|
class Voice {
|
||||||
public:
|
public:
|
||||||
Voice(std::string name, std::string channel, std::string font, int size, ColorA8u color, ColorA8u background, Rectf bounds, std::function<void(Voice*)> utterance_cb, std::function<void(Voice*)> change_cb)
|
Voice(std::string name, std::string channel, std::string font, int size, ColorA8u color, ColorA8u background, float temp, Rectf bounds, std::function<void(Voice*)> utterance_cb, std::function<void(Voice*)> change_cb)
|
||||||
: _name(name),
|
: _name(name),
|
||||||
_channel(channel),
|
_channel(channel),
|
||||||
_utterance(name),
|
_utterance(name),
|
||||||
@ -33,6 +33,7 @@ public:
|
|||||||
_size(size),
|
_size(size),
|
||||||
_color(color),
|
_color(color),
|
||||||
_background(background),
|
_background(background),
|
||||||
|
_temperature(temp),
|
||||||
_bounds(bounds),
|
_bounds(bounds),
|
||||||
_offset(vec2(0)),
|
_offset(vec2(0)),
|
||||||
_utterance_cb(utterance_cb),
|
_utterance_cb(utterance_cb),
|
||||||
@ -55,6 +56,7 @@ public:
|
|||||||
int _size;
|
int _size;
|
||||||
bool _update_font = false;
|
bool _update_font = false;
|
||||||
float _temperature;
|
float _temperature;
|
||||||
|
std::string _temperature_str;
|
||||||
|
|
||||||
gl::TextureFontRef _tex;
|
gl::TextureFontRef _tex;
|
||||||
gl::TextureFontRef _tex_name;
|
gl::TextureFontRef _tex_name;
|
||||||
|
|||||||
@ -115,6 +115,8 @@ void VoiceMachineApp::stage_config()
|
|||||||
ColorA8u color = ColorA8u::hexA(std::stoul(hexcolor, nullptr, 16));
|
ColorA8u color = ColorA8u::hexA(std::stoul(hexcolor, nullptr, 16));
|
||||||
std::string hexbackground = voice["background"].getValue();
|
std::string hexbackground = voice["background"].getValue();
|
||||||
ColorA background = ColorA::hexA(std::stoul(hexbackground, nullptr, 16));
|
ColorA background = ColorA::hexA(std::stoul(hexbackground, nullptr, 16));
|
||||||
|
std::string tempstr = voice["model"]["temperature"].getValue();
|
||||||
|
float temp = std::stof(tempstr);
|
||||||
|
|
||||||
std::function<void(Voice*)> utterance_cb = [=](Voice* v) {
|
std::function<void(Voice*)> utterance_cb = [=](Voice* v) {
|
||||||
this->utterance(v);
|
this->utterance(v);
|
||||||
@ -124,7 +126,7 @@ void VoiceMachineApp::stage_config()
|
|||||||
this->change(v);
|
this->change(v);
|
||||||
};
|
};
|
||||||
|
|
||||||
Voice* v = new Voice(name, channel, font, size, color, background, bounds, utterance_cb, change_cb);
|
Voice* v = new Voice(name, channel, font, size, color, background, temp, bounds, utterance_cb, change_cb);
|
||||||
_map_voices[name] = v;
|
_map_voices[name] = v;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user