MCPcopy Create free account
hub / github.com/BatchDrake/SigDigger / exportToWav

Method exportToWav

Tasks/ExportSamplesTask.cpp:105–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103}
104
105bool
106ExportSamplesTask::exportToWav(void)
107{
108 size_t size = this->data.size();
109 bool ok = false;
110 size_t i = 0;
111 size_t amount;
112
113 for (
114 i = 0;
115 !this->cancelFlag && i < size;
116 i += SIGDIGGER_EXPORT_SAMPLES_BREATHE_BLOCK_SIZE) {
117
118 amount = size - i;
119 if (amount > SIGDIGGER_EXPORT_SAMPLES_BREATHE_BLOCK_SIZE)
120 amount = SIGDIGGER_EXPORT_SAMPLES_BREATHE_BLOCK_SIZE;
121
122 if (sf_write_float(
123 this->sfp,
124 reinterpret_cast<const SUFLOAT *>(this->data.data() + i),
125 2 * amount)
126 != 2 * static_cast<sf_count_t>(amount))
127 goto done;
128
129 this->breathe(i);
130 }
131
132 if (i < size)
133 if (sf_write_float(
134 this->sfp,
135 reinterpret_cast<const SUFLOAT *>(this->data.data() + i),
136 2 * static_cast<sf_count_t>(size - i)) !=
137 2 * static_cast<sf_count_t>(size - i))
138 goto done;
139
140 ok = true;
141
142done:
143 if (!ok)
144 emit error(
145 "Cannot save data to WAV/RAW file "
146 + this->path
147 + ": "
148 + QString(sf_strerror(this->sfp)));
149
150 return ok;
151}
152
153bool
154ExportSamplesTask::work(void)

Callers 1

workMethod · 0.95

Calls 3

breatheMethod · 0.95
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected