mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Starts the movement towards a world without PCMPatchedTrack.
This commit is contained in:
parent
cd464fc7de
commit
16bef0dcd5
@ -39,17 +39,34 @@ PCMTrack::PCMTrack(const PCMSegment &segment) : PCMTrack() {
|
||||
PCMSegment length_adjusted_segment = segment;
|
||||
length_adjusted_segment.length_of_a_bit.length = 1;
|
||||
length_adjusted_segment.length_of_a_bit.clock_rate = segment.number_of_bits;
|
||||
segment_event_sources_.emplace_back(length_adjusted_segment);
|
||||
segment_event_sources_.emplace_back(std::move(length_adjusted_segment));
|
||||
}
|
||||
|
||||
PCMTrack::PCMTrack(const PCMTrack &original) : PCMTrack() {
|
||||
segment_event_sources_ = original.segment_event_sources_;
|
||||
}
|
||||
|
||||
PCMTrack::PCMTrack(unsigned int bits_per_track) : PCMTrack() {
|
||||
PCMSegment segment;
|
||||
segment.length_of_a_bit.length = 1;
|
||||
segment.length_of_a_bit.clock_rate = bits_per_track;
|
||||
segment.data.resize((bits_per_track + 7) >> 3);
|
||||
segment_event_sources_.emplace_back(segment);
|
||||
}
|
||||
|
||||
Track *PCMTrack::clone() const {
|
||||
return new PCMTrack(*this);
|
||||
}
|
||||
|
||||
Track *PCMTrack::resampled_clone(size_t bits_per_track) {
|
||||
PCMTrack *new_track = new PCMTrack(bits_per_track);
|
||||
|
||||
// for(const auto &event_source : segment_event_sources_) {
|
||||
// }
|
||||
|
||||
return new_track;
|
||||
}
|
||||
|
||||
Track::Event PCMTrack::get_next_event() {
|
||||
// ask the current segment for a new event
|
||||
Track::Event event = segment_event_sources_[segment_pointer_].get_next_event();
|
||||
@ -108,3 +125,4 @@ Storage::Time PCMTrack::seek_to(const Time &time_since_index_hole) {
|
||||
// the list of segments
|
||||
return accumulated_time;
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include "Track.hpp"
|
||||
#include "PCMSegment.hpp"
|
||||
#include "../../../ClockReceiver/ClockReceiver.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace Storage {
|
||||
@ -46,7 +48,31 @@ class PCMTrack: public Track {
|
||||
Time seek_to(const Time &time_since_index_hole) override;
|
||||
Track *clone() const override;
|
||||
|
||||
// Obtains a copy of this track, flattened to a single PCMSegment, which
|
||||
// consists of @c bits_per_track potential flux transition points.
|
||||
Track *resampled_clone(size_t bits_per_track);
|
||||
|
||||
/*!
|
||||
Replaces whatever is currently on the track from @c start_position to @c start_position + segment length
|
||||
with the contents of @c segment.
|
||||
|
||||
This is a well-defined operation only for tracks with a single segment. The new segment will be resampled
|
||||
to the track's underlying segment, which will be mutated.
|
||||
|
||||
@param start_time The time at which this segment begins. Must be in the range [0, 1).
|
||||
@param segment The PCM segment to add.
|
||||
@param clamp_to_index_hole If @c true then the new segment will be truncated if it overruns the index hole;
|
||||
it will otherwise write over the index hole and continue.
|
||||
*/
|
||||
void add_segment(const Time &start_time, const PCMSegment &segment, bool clamp_to_index_hole);
|
||||
|
||||
private:
|
||||
/*!
|
||||
Creates a PCMTrack with a single segment, consisting of @c bits_per_track flux windows,
|
||||
initialised with no flux events.
|
||||
*/
|
||||
PCMTrack(unsigned int bits_per_track);
|
||||
|
||||
// storage for the segments that describe this track
|
||||
std::vector<PCMSegmentEventSource> segment_event_sources_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user