mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Slightly improves syntax.
This commit is contained in:
parent
9f0f35033d
commit
c123ca1054
@ -165,7 +165,7 @@ void PCMTrack::add_segment(const Time &start_time, const PCMSegment &segment, bo
|
||||
const size_t selected_end_bit = std::min(end_bit, destination.data.size());
|
||||
|
||||
// Reset the destination.
|
||||
std::fill(destination.data.begin() + static_cast<off_t>(start_bit), destination.data.begin() + static_cast<off_t>(selected_end_bit), false);
|
||||
std::fill(destination.data.begin() + off_t(start_bit), destination.data.begin() + off_t(selected_end_bit), false);
|
||||
|
||||
// Step through the source data from start to finish, stopping early if it goes out of bounds.
|
||||
for(size_t bit = 0; bit < segment.data.size(); ++bit) {
|
||||
@ -184,15 +184,19 @@ void PCMTrack::add_segment(const Time &start_time, const PCMSegment &segment, bo
|
||||
if(target_width >= destination.data.size()) {
|
||||
std::fill(destination.data.begin(), destination.data.end(), false);
|
||||
} else {
|
||||
std::fill(destination.data.begin(), destination.data.begin() + static_cast<off_t>(end_bit % destination.data.size()), false);
|
||||
std::fill(destination.data.begin() + static_cast<off_t>(start_bit), destination.data.end(), false);
|
||||
std::fill(destination.data.begin(), destination.data.begin() + off_t(end_bit % destination.data.size()), false);
|
||||
std::fill(destination.data.begin() + off_t(start_bit), destination.data.end(), false);
|
||||
}
|
||||
|
||||
// Run backwards from final bit back to first, stopping early if overlapping the beginning.
|
||||
for(off_t bit = static_cast<off_t>(segment.data.size()-1); bit >= 0; --bit) {
|
||||
if(segment.data[static_cast<size_t>(bit)]) {
|
||||
const size_t output_bit = start_bit + half_offset + (static_cast<size_t>(bit) * target_width) / segment.data.size();
|
||||
if(output_bit <= end_bit - destination.data.size()) return;
|
||||
for(off_t bit = off_t(segment.data.size()-1); bit >= 0; --bit) {
|
||||
// Store flux transitions only; non-transitions can be ignored.
|
||||
if(segment.data[size_t(bit)]) {
|
||||
// Map to the proper output destination; stop if now potentially overwriting where we began.
|
||||
const size_t output_bit = start_bit + half_offset + (size_t(bit) * target_width) / segment.data.size();
|
||||
if(output_bit < end_bit - destination.data.size()) return;
|
||||
|
||||
// Store.
|
||||
destination.data[output_bit % destination.data.size()] = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user