2016-07-10 22:36:52 +00:00
|
|
|
//
|
|
|
|
// PCMTrack.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 10/07/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef PCMTrack_hpp
|
|
|
|
#define PCMTrack_hpp
|
|
|
|
|
|
|
|
#include "Disk.hpp"
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Storage {
|
2016-08-27 21:15:09 +00:00
|
|
|
namespace Disk {
|
2016-07-10 22:36:52 +00:00
|
|
|
|
|
|
|
/*!
|
2016-07-15 10:51:11 +00:00
|
|
|
A segment of PCM-sampled data.
|
2016-07-10 22:36:52 +00:00
|
|
|
|
|
|
|
Bits from each byte are taken MSB to LSB.
|
|
|
|
*/
|
|
|
|
struct PCMSegment {
|
2016-07-15 10:51:11 +00:00
|
|
|
Time length_of_a_bit;
|
|
|
|
unsigned int number_of_bits;
|
2016-09-18 22:56:35 +00:00
|
|
|
std::vector<uint8_t> data;
|
2016-07-10 22:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
A subclass of @c Track that provides its @c Events by querying a pulse-code modulated record of original
|
|
|
|
flux detections, with an implied index hole at the very start of the data.
|
|
|
|
|
|
|
|
The data may consist of a single @c PCMSegment or of multiple, allowing a PCM-format track to contain
|
|
|
|
multiple distinct segments of data, each with a separate clock rate.
|
|
|
|
*/
|
|
|
|
class PCMTrack: public Track {
|
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
Creates a @c PCMTrack consisting of multiple segments of data, permitting multiple clock rates.
|
|
|
|
*/
|
|
|
|
PCMTrack(std::vector<PCMSegment> segments);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Creates a @c PCMTrack consisting of a single continuous run of data, implying a constant clock rate.
|
2016-08-01 12:41:16 +00:00
|
|
|
The segment's @c length_of_a_bit will be ignored and therefore need not be filled in.
|
2016-07-10 22:36:52 +00:00
|
|
|
*/
|
|
|
|
PCMTrack(PCMSegment segment);
|
|
|
|
|
|
|
|
// as per @c Track
|
|
|
|
Event get_next_event();
|
2016-08-03 10:59:45 +00:00
|
|
|
Time seek_to(Time time_since_index_hole);
|
2016-07-10 22:36:52 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// storage for the segments that describe this track
|
2016-12-03 16:59:28 +00:00
|
|
|
std::vector<PCMSegment> segments_;
|
2016-07-10 22:36:52 +00:00
|
|
|
|
|
|
|
// a helper to determine the overall track clock rate and it's length
|
|
|
|
void fix_length();
|
|
|
|
|
|
|
|
// the event perpetually returned; impliedly contains the length of the entire track
|
|
|
|
// as its clock rate, per the need for everything on a Track to sum to a length of 1
|
2016-12-03 16:59:28 +00:00
|
|
|
PCMTrack::Event next_event_;
|
2016-07-10 22:36:52 +00:00
|
|
|
|
|
|
|
// contains the master clock rate
|
2016-12-03 16:59:28 +00:00
|
|
|
unsigned int track_clock_rate_;
|
2016-07-10 22:36:52 +00:00
|
|
|
|
|
|
|
// a pointer to the first bit to consider as the next event
|
2016-12-03 16:59:28 +00:00
|
|
|
size_t segment_pointer_;
|
|
|
|
size_t bit_pointer_;
|
2016-07-10 22:36:52 +00:00
|
|
|
};
|
|
|
|
|
2016-08-27 21:15:09 +00:00
|
|
|
}
|
2016-07-10 22:36:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* PCMTrack_hpp */
|