Mercurial > hg > svcore
comparison data/model/WritableWaveFileModel.h @ 1337:3dcd83595bc8 3.0-integration
Make writable model updating explicit rather than essentially an arbitrary hidden accident
author | Chris Cannam |
---|---|
date | Wed, 04 Jan 2017 14:22:39 +0000 |
parents | 54af1e21705c |
children | 925d205c39b4 |
comparison
equal
deleted
inserted
replaced
1336:dc56e8a13e44 | 1337:3dcd83595bc8 |
---|---|
31 WritableWaveFileModel(sv_samplerate_t sampleRate, int channels, QString path = ""); | 31 WritableWaveFileModel(sv_samplerate_t sampleRate, int channels, QString path = ""); |
32 ~WritableWaveFileModel(); | 32 ~WritableWaveFileModel(); |
33 | 33 |
34 /** | 34 /** |
35 * Call addSamples to append a block of samples to the end of the | 35 * Call addSamples to append a block of samples to the end of the |
36 * file. Caller should also call setWriteProportion() to update | 36 * file. |
37 * the progress of this file, if it has a known end point, and | 37 * |
38 * should call writeComplete() when the file has been written. | 38 * This function only appends the samples to the file being |
39 * written; it does not update the model's view of the samples in | |
40 * that file. That is, it updates the file on disc but the model | |
41 * itself does not change its content. This is because re-reading | |
42 * the file to update the model may be more expensive than adding | |
43 * the samples in the first place. If you are writing small | |
44 * numbers of samples repeatedly, you probably only want the model | |
45 * to update periodically rather than after every write. | |
46 * | |
47 * Call updateModel() periodically to tell the model to update its | |
48 * own view of the samples in the file being written. | |
49 * | |
50 * Call setWriteProportion() periodically if the file being | |
51 * written has known duration and you want the model to be able to | |
52 * report the write progress as a percentage. | |
53 * | |
54 * Call writeComplete() when the file has been completely written. | |
39 */ | 55 */ |
40 virtual bool addSamples(const float *const *samples, sv_frame_t count); | 56 virtual bool addSamples(const float *const *samples, sv_frame_t count); |
41 | 57 |
58 /** | |
59 * Tell the model to update its own (read) view of the (written) | |
60 * file. May cause modelChanged() and modelChangedWithin() to be | |
61 * emitted. See the comment to addSamples above for rationale. | |
62 */ | |
63 void updateModel(); | |
64 | |
42 /** | 65 /** |
43 * Set the proportion of the file which has been written so far, | 66 * Set the proportion of the file which has been written so far, |
44 * as a percentage. This may be used to indicate progress. | 67 * as a percentage. This may be used to indicate progress. |
45 * | 68 * |
46 * Note that this differs from the "completion" percentage | 69 * Note that this differs from the "completion" percentage |
54 */ | 77 */ |
55 void setWriteProportion(int proportion); | 78 void setWriteProportion(int proportion); |
56 | 79 |
57 /** | 80 /** |
58 * Indicate that writing is complete. You should call this even if | 81 * Indicate that writing is complete. You should call this even if |
59 * you have never called setWriteProportion(). | 82 * you have never called setWriteProportion() or updateModel(). |
60 */ | 83 */ |
61 void writeComplete(); | 84 void writeComplete(); |
62 | 85 |
63 static const int PROPORTION_UNKNOWN; | 86 static const int PROPORTION_UNKNOWN; |
64 | 87 |