| 103 | } |
| 104 | |
| 105 | bool |
| 106 | ExportSamplesTask::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 | |
| 142 | done: |
| 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 | |
| 153 | bool |
| 154 | ExportSamplesTask::work(void) |