instruction improvements
This commit is contained in:
parent
34f26ae46f
commit
f763871106
|
@ -19,9 +19,8 @@ void packet::Clear::finalise(std::ostream& dst) const {
|
|||
void packet::ClearTS::finalise(std::ostream& dst) const {
|
||||
uint64_t v = Type::clear_ts & bm(3);
|
||||
v = (v << 5) | (index & bm(5));
|
||||
v = (v << 18) | (ticks & bm(18));
|
||||
v <<= 6;
|
||||
output(dst, v, 4);
|
||||
v = (v << 16) | (ticks & bm(16));
|
||||
output(dst, v, 3);
|
||||
}
|
||||
|
||||
void packet::Set::finalise(std::ostream& dst) const {
|
||||
|
@ -29,16 +28,17 @@ void packet::Set::finalise(std::ostream& dst) const {
|
|||
v = (v << 5) | (index & bm(5));
|
||||
v = (v << 12) | (frequency & bm(12));
|
||||
v = (v << 2) | (mode & bm(2));
|
||||
v <<= 2;
|
||||
v = (v << 2) | (gain & bm(2));
|
||||
output(dst, v, 3);
|
||||
}
|
||||
|
||||
void packet::SetTS::finalise(std::ostream& dst) const {
|
||||
uint64_t v = Type::set_ts & bm(3);
|
||||
v = (v << 5) | (index & bm(5));
|
||||
v = (v << 18) | (ticks & bm(18));
|
||||
v = (v << 16) | (ticks & bm(16));
|
||||
v = (v << 12) | (frequency & bm(12));
|
||||
v = (v << 2) | (mode & bm(2));
|
||||
v = (v << 2) | (gain & bm(2));
|
||||
output(dst, v, 5);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace packet {
|
|||
unsigned index;
|
||||
unsigned frequency;
|
||||
ToneType mode;
|
||||
unsigned gain;
|
||||
|
||||
void finalise(std::ostream& dst) const;
|
||||
};
|
||||
|
@ -39,6 +40,7 @@ namespace packet {
|
|||
unsigned ticks;
|
||||
unsigned frequency;
|
||||
ToneType mode;
|
||||
unsigned gain;
|
||||
|
||||
void finalise(std::ostream& dst) const;
|
||||
};
|
||||
|
@ -69,7 +71,7 @@ namespace packet {
|
|||
case Type::clear:
|
||||
return 1;
|
||||
case Type::clear_ts:
|
||||
return 4;
|
||||
return 3;
|
||||
case Type::set:
|
||||
return 3;
|
||||
case Type::set_ts:
|
||||
|
|
|
@ -31,7 +31,7 @@ bool Scheduler::add_note(unsigned key_id, unsigned ticks, bool state, packet::To
|
|||
if(ticks_at >= ticks) {
|
||||
packets.push_back({.type=packet::Type::clear, .clear={.index=channel}});
|
||||
} else {
|
||||
packets.push_back({.type=packet::Type::clear_ts, .clear_ts={.index=channel, .ticks=ticks}});
|
||||
packets.push_back({.type=packet::Type::clear_ts, .clear_ts={.index=channel, .ticks=ticks - ticks_at}});
|
||||
ticks_at = ticks;
|
||||
}
|
||||
return true;
|
||||
|
@ -55,9 +55,26 @@ bool Scheduler::add_note(unsigned key_id, unsigned ticks, bool state, packet::To
|
|||
}
|
||||
|
||||
if(ticks_at >= ticks) {
|
||||
packets.push_back({.type=packet::Type::set, .set={.index=channel_id, .frequency=key::get_freq(key_id), .mode=mode}});
|
||||
packets.push_back({
|
||||
.type=packet::Type::set,
|
||||
.set={
|
||||
.index=channel_id,
|
||||
.frequency=key::get_freq(key_id),
|
||||
.mode=mode,
|
||||
.gain=0,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
packets.push_back({.type=packet::Type::set_ts, .set_ts={.index=channel_id, .ticks=ticks, .frequency=key::get_freq(key_id), .mode=mode}});
|
||||
packets.push_back({
|
||||
.type=packet::Type::set_ts,
|
||||
.set_ts={
|
||||
.index=channel_id,
|
||||
.ticks=ticks - ticks_at,
|
||||
.frequency=key::get_freq(key_id),
|
||||
.mode=mode,
|
||||
.gain=0,
|
||||
},
|
||||
});
|
||||
ticks_at = ticks;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue