The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

616 lines
22KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. #if JUCE_USE_FLAC
  16. }
  17. #if defined _WIN32 && !defined __CYGWIN__
  18. #include <io.h>
  19. #else
  20. #include <unistd.h>
  21. #endif
  22. #if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
  23. #include <sys/types.h> /* for off_t */
  24. #endif
  25. #if HAVE_INTTYPES_H
  26. #define __STDC_FORMAT_MACROS
  27. #include <inttypes.h>
  28. #endif
  29. #if defined _MSC_VER || defined __MINGW32__ || defined __CYGWIN__ || defined __EMX__
  30. #include <io.h> /* for _setmode(), chmod() */
  31. #include <fcntl.h> /* for _O_BINARY */
  32. #else
  33. #include <unistd.h> /* for chown(), unlink() */
  34. #endif
  35. #if defined _MSC_VER || defined __BORLANDC__ || defined __MINGW32__
  36. #if defined __BORLANDC__
  37. #include <utime.h> /* for utime() */
  38. #else
  39. #include <sys/utime.h> /* for utime() */
  40. #endif
  41. #else
  42. #include <sys/types.h> /* some flavors of BSD (like OS X) require this to get time_t */
  43. #include <utime.h> /* for utime() */
  44. #endif
  45. #if defined _MSC_VER
  46. #if _MSC_VER >= 1600
  47. #include <stdint.h>
  48. #else
  49. #include <limits.h>
  50. #endif
  51. #endif
  52. #ifdef _WIN32
  53. #include <stdio.h>
  54. #include <sys/stat.h>
  55. #include <stdarg.h>
  56. #include <windows.h>
  57. #endif
  58. #ifdef DEBUG
  59. #include <assert.h>
  60. #endif
  61. #include <stdlib.h>
  62. #include <stdio.h>
  63. namespace juce
  64. {
  65. namespace FlacNamespace
  66. {
  67. #if JUCE_INCLUDE_FLAC_CODE || ! defined (JUCE_INCLUDE_FLAC_CODE)
  68. #undef VERSION
  69. #define VERSION "1.3.1"
  70. #define FLAC__NO_DLL 1
  71. #if JUCE_MSVC
  72. #pragma warning (disable: 4267 4127 4244 4996 4100 4701 4702 4013 4133 4206 4312 4505 4365 4005 4334 181 111)
  73. #else
  74. #define HAVE_LROUND 1
  75. #endif
  76. #if JUCE_MAC
  77. #define FLAC__SYS_DARWIN 1
  78. #endif
  79. #ifndef SIZE_MAX
  80. #define SIZE_MAX 0xffffffff
  81. #endif
  82. #if JUCE_CLANG
  83. #pragma clang diagnostic push
  84. #pragma clang diagnostic ignored "-Wconversion"
  85. #pragma clang diagnostic ignored "-Wshadow"
  86. #pragma clang diagnostic ignored "-Wdeprecated-register"
  87. #pragma clang diagnostic ignored "-Wswitch-enum"
  88. #if __has_warning ("-Wimplicit-fallthrough")
  89. #pragma clang diagnostic ignored "-Wimplicit-fallthrough"
  90. #endif
  91. #if __has_warning("-Wzero-as-null-pointer-constant")
  92. #pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
  93. #endif
  94. #endif
  95. #if JUCE_GCC
  96. #pragma GCC diagnostic push
  97. #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
  98. #pragma GCC diagnostic ignored "-Wconversion"
  99. #pragma GCC diagnostic ignored "-Wsign-conversion"
  100. #pragma GCC diagnostic ignored "-Wswitch-enum"
  101. #pragma GCC diagnostic ignored "-Wswitch-default"
  102. #pragma GCC diagnostic ignored "-Wredundant-decls"
  103. #if __GNUC__ >= 7
  104. #pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
  105. #endif
  106. #endif
  107. #if JUCE_INTEL
  108. #if JUCE_32BIT
  109. #define FLAC__CPU_IA32 1
  110. #endif
  111. #if JUCE_64BIT
  112. #define FLAC__CPU_X86_64 1
  113. #endif
  114. #define FLAC__HAS_X86INTRIN 1
  115. #endif
  116. #undef __STDC_LIMIT_MACROS
  117. #define __STDC_LIMIT_MACROS 1
  118. #define flac_max jmax
  119. #define flac_min jmin
  120. #undef DEBUG // (some flac code dumps debug trace if the app defines this macro)
  121. #include "flac/all.h"
  122. #include "flac/libFLAC/bitmath.c"
  123. #include "flac/libFLAC/bitreader.c"
  124. #include "flac/libFLAC/bitwriter.c"
  125. #include "flac/libFLAC/cpu.c"
  126. #include "flac/libFLAC/crc.c"
  127. #include "flac/libFLAC/fixed.c"
  128. #include "flac/libFLAC/float.c"
  129. #include "flac/libFLAC/format.c"
  130. #include "flac/libFLAC/lpc_flac.c"
  131. #include "flac/libFLAC/md5.c"
  132. #include "flac/libFLAC/memory.c"
  133. #include "flac/libFLAC/stream_decoder.c"
  134. #include "flac/libFLAC/stream_encoder.c"
  135. #include "flac/libFLAC/stream_encoder_framing.c"
  136. #include "flac/libFLAC/window_flac.c"
  137. #undef VERSION
  138. #else
  139. #include <FLAC/all.h>
  140. #endif
  141. #if JUCE_CLANG
  142. #pragma clang diagnostic pop
  143. #endif
  144. #if JUCE_GCC
  145. #pragma GCC diagnostic pop
  146. #endif
  147. }
  148. #undef max
  149. #undef min
  150. //==============================================================================
  151. static const char* const flacFormatName = "FLAC file";
  152. //==============================================================================
  153. class FlacReader : public AudioFormatReader
  154. {
  155. public:
  156. FlacReader (InputStream* in) : AudioFormatReader (in, flacFormatName)
  157. {
  158. lengthInSamples = 0;
  159. decoder = FlacNamespace::FLAC__stream_decoder_new();
  160. ok = FLAC__stream_decoder_init_stream (decoder,
  161. readCallback_, seekCallback_, tellCallback_, lengthCallback_,
  162. eofCallback_, writeCallback_, metadataCallback_, errorCallback_,
  163. this) == FlacNamespace::FLAC__STREAM_DECODER_INIT_STATUS_OK;
  164. if (ok)
  165. {
  166. FLAC__stream_decoder_process_until_end_of_metadata (decoder);
  167. if (lengthInSamples == 0 && sampleRate > 0)
  168. {
  169. // the length hasn't been stored in the metadata, so we'll need to
  170. // work it out the length the hard way, by scanning the whole file..
  171. scanningForLength = true;
  172. FLAC__stream_decoder_process_until_end_of_stream (decoder);
  173. scanningForLength = false;
  174. auto tempLength = lengthInSamples;
  175. FLAC__stream_decoder_reset (decoder);
  176. FLAC__stream_decoder_process_until_end_of_metadata (decoder);
  177. lengthInSamples = tempLength;
  178. }
  179. }
  180. }
  181. ~FlacReader() override
  182. {
  183. FlacNamespace::FLAC__stream_decoder_delete (decoder);
  184. }
  185. void useMetadata (const FlacNamespace::FLAC__StreamMetadata_StreamInfo& info)
  186. {
  187. sampleRate = info.sample_rate;
  188. bitsPerSample = info.bits_per_sample;
  189. lengthInSamples = (unsigned int) info.total_samples;
  190. numChannels = info.channels;
  191. reservoir.setSize ((int) numChannels, 2 * (int) info.max_blocksize, false, false, true);
  192. }
  193. // returns the number of samples read
  194. bool readSamples (int** destSamples, int numDestChannels, int startOffsetInDestBuffer,
  195. int64 startSampleInFile, int numSamples) override
  196. {
  197. if (! ok)
  198. return false;
  199. while (numSamples > 0)
  200. {
  201. if (startSampleInFile >= reservoirStart
  202. && startSampleInFile < reservoirStart + samplesInReservoir)
  203. {
  204. auto num = (int) jmin ((int64) numSamples,
  205. reservoirStart + samplesInReservoir - startSampleInFile);
  206. jassert (num > 0);
  207. for (int i = jmin (numDestChannels, reservoir.getNumChannels()); --i >= 0;)
  208. if (destSamples[i] != nullptr)
  209. memcpy (destSamples[i] + startOffsetInDestBuffer,
  210. reservoir.getReadPointer (i, (int) (startSampleInFile - reservoirStart)),
  211. (size_t) num * sizeof (int));
  212. startOffsetInDestBuffer += num;
  213. startSampleInFile += num;
  214. numSamples -= num;
  215. }
  216. else
  217. {
  218. if (startSampleInFile >= lengthInSamples)
  219. {
  220. samplesInReservoir = 0;
  221. }
  222. else if (startSampleInFile < reservoirStart
  223. || startSampleInFile > reservoirStart + jmax (samplesInReservoir, 511))
  224. {
  225. // had some problems with flac crashing if the read pos is aligned more
  226. // accurately than this. Probably fixed in newer versions of the library, though.
  227. reservoirStart = (int) (startSampleInFile & ~511);
  228. samplesInReservoir = 0;
  229. FLAC__stream_decoder_seek_absolute (decoder, (FlacNamespace::FLAC__uint64) reservoirStart);
  230. }
  231. else
  232. {
  233. reservoirStart += samplesInReservoir;
  234. samplesInReservoir = 0;
  235. FLAC__stream_decoder_process_single (decoder);
  236. }
  237. if (samplesInReservoir == 0)
  238. break;
  239. }
  240. }
  241. if (numSamples > 0)
  242. {
  243. for (int i = numDestChannels; --i >= 0;)
  244. if (destSamples[i] != nullptr)
  245. zeromem (destSamples[i] + startOffsetInDestBuffer, (size_t) numSamples * sizeof (int));
  246. }
  247. return true;
  248. }
  249. void useSamples (const FlacNamespace::FLAC__int32* const buffer[], int numSamples)
  250. {
  251. if (scanningForLength)
  252. {
  253. lengthInSamples += numSamples;
  254. }
  255. else
  256. {
  257. if (numSamples > reservoir.getNumSamples())
  258. reservoir.setSize ((int) numChannels, numSamples, false, false, true);
  259. auto bitsToShift = 32 - bitsPerSample;
  260. for (int i = 0; i < (int) numChannels; ++i)
  261. {
  262. auto* src = buffer[i];
  263. int n = i;
  264. while (src == nullptr && n > 0)
  265. src = buffer [--n];
  266. if (src != nullptr)
  267. {
  268. auto* dest = reinterpret_cast<int*> (reservoir.getWritePointer(i));
  269. for (int j = 0; j < numSamples; ++j)
  270. dest[j] = src[j] << bitsToShift;
  271. }
  272. }
  273. samplesInReservoir = numSamples;
  274. }
  275. }
  276. //==============================================================================
  277. static FlacNamespace::FLAC__StreamDecoderReadStatus readCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__byte buffer[], size_t* bytes, void* client_data)
  278. {
  279. *bytes = (size_t) static_cast<const FlacReader*> (client_data)->input->read (buffer, (int) *bytes);
  280. return FlacNamespace::FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
  281. }
  282. static FlacNamespace::FLAC__StreamDecoderSeekStatus seekCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__uint64 absolute_byte_offset, void* client_data)
  283. {
  284. static_cast<const FlacReader*> (client_data)->input->setPosition ((int) absolute_byte_offset);
  285. return FlacNamespace::FLAC__STREAM_DECODER_SEEK_STATUS_OK;
  286. }
  287. static FlacNamespace::FLAC__StreamDecoderTellStatus tellCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__uint64* absolute_byte_offset, void* client_data)
  288. {
  289. *absolute_byte_offset = (uint64) static_cast<const FlacReader*> (client_data)->input->getPosition();
  290. return FlacNamespace::FLAC__STREAM_DECODER_TELL_STATUS_OK;
  291. }
  292. static FlacNamespace::FLAC__StreamDecoderLengthStatus lengthCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__uint64* stream_length, void* client_data)
  293. {
  294. *stream_length = (uint64) static_cast<const FlacReader*> (client_data)->input->getTotalLength();
  295. return FlacNamespace::FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
  296. }
  297. static FlacNamespace::FLAC__bool eofCallback_ (const FlacNamespace::FLAC__StreamDecoder*, void* client_data)
  298. {
  299. return static_cast<const FlacReader*> (client_data)->input->isExhausted();
  300. }
  301. static FlacNamespace::FLAC__StreamDecoderWriteStatus writeCallback_ (const FlacNamespace::FLAC__StreamDecoder*,
  302. const FlacNamespace::FLAC__Frame* frame,
  303. const FlacNamespace::FLAC__int32* const buffer[],
  304. void* client_data)
  305. {
  306. static_cast<FlacReader*> (client_data)->useSamples (buffer, (int) frame->header.blocksize);
  307. return FlacNamespace::FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
  308. }
  309. static void metadataCallback_ (const FlacNamespace::FLAC__StreamDecoder*,
  310. const FlacNamespace::FLAC__StreamMetadata* metadata,
  311. void* client_data)
  312. {
  313. static_cast<FlacReader*> (client_data)->useMetadata (metadata->data.stream_info);
  314. }
  315. static void errorCallback_ (const FlacNamespace::FLAC__StreamDecoder*, FlacNamespace::FLAC__StreamDecoderErrorStatus, void*)
  316. {
  317. }
  318. private:
  319. FlacNamespace::FLAC__StreamDecoder* decoder;
  320. AudioBuffer<float> reservoir;
  321. int reservoirStart = 0, samplesInReservoir = 0;
  322. bool ok = false, scanningForLength = false;
  323. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FlacReader)
  324. };
  325. //==============================================================================
  326. class FlacWriter : public AudioFormatWriter
  327. {
  328. public:
  329. FlacWriter (OutputStream* out, double rate, uint32 numChans, uint32 bits, int qualityOptionIndex)
  330. : AudioFormatWriter (out, flacFormatName, rate, numChans, bits),
  331. streamStartPos (output != nullptr ? jmax (output->getPosition(), 0ll) : 0ll)
  332. {
  333. encoder = FlacNamespace::FLAC__stream_encoder_new();
  334. if (qualityOptionIndex > 0)
  335. FLAC__stream_encoder_set_compression_level (encoder, (uint32) jmin (8, qualityOptionIndex));
  336. FLAC__stream_encoder_set_do_mid_side_stereo (encoder, numChannels == 2);
  337. FLAC__stream_encoder_set_loose_mid_side_stereo (encoder, numChannels == 2);
  338. FLAC__stream_encoder_set_channels (encoder, numChannels);
  339. FLAC__stream_encoder_set_bits_per_sample (encoder, jmin ((unsigned int) 24, bitsPerSample));
  340. FLAC__stream_encoder_set_sample_rate (encoder, (unsigned int) sampleRate);
  341. FLAC__stream_encoder_set_blocksize (encoder, 0);
  342. FLAC__stream_encoder_set_do_escape_coding (encoder, true);
  343. ok = FLAC__stream_encoder_init_stream (encoder,
  344. encodeWriteCallback, encodeSeekCallback,
  345. encodeTellCallback, encodeMetadataCallback,
  346. this) == FlacNamespace::FLAC__STREAM_ENCODER_INIT_STATUS_OK;
  347. }
  348. ~FlacWriter() override
  349. {
  350. if (ok)
  351. {
  352. FlacNamespace::FLAC__stream_encoder_finish (encoder);
  353. output->flush();
  354. }
  355. else
  356. {
  357. output = nullptr; // to stop the base class deleting this, as it needs to be returned
  358. // to the caller of createWriter()
  359. }
  360. FlacNamespace::FLAC__stream_encoder_delete (encoder);
  361. }
  362. //==============================================================================
  363. bool write (const int** samplesToWrite, int numSamples) override
  364. {
  365. if (! ok)
  366. return false;
  367. HeapBlock<int*> channels;
  368. HeapBlock<int> temp;
  369. auto bitsToShift = 32 - (int) bitsPerSample;
  370. if (bitsToShift > 0)
  371. {
  372. temp.malloc (numChannels * (size_t) numSamples);
  373. channels.calloc (numChannels + 1);
  374. for (unsigned int i = 0; i < numChannels; ++i)
  375. {
  376. if (samplesToWrite[i] == nullptr)
  377. break;
  378. auto* destData = temp.get() + i * (size_t) numSamples;
  379. channels[i] = destData;
  380. for (int j = 0; j < numSamples; ++j)
  381. destData[j] = (samplesToWrite[i][j] >> bitsToShift);
  382. }
  383. samplesToWrite = const_cast<const int**> (channels.get());
  384. }
  385. return FLAC__stream_encoder_process (encoder, (const FlacNamespace::FLAC__int32**) samplesToWrite, (unsigned) numSamples) != 0;
  386. }
  387. bool writeData (const void* const data, const int size) const
  388. {
  389. return output->write (data, (size_t) size);
  390. }
  391. static void packUint32 (FlacNamespace::FLAC__uint32 val, FlacNamespace::FLAC__byte* b, const int bytes)
  392. {
  393. b += bytes;
  394. for (int i = 0; i < bytes; ++i)
  395. {
  396. *(--b) = (FlacNamespace::FLAC__byte) (val & 0xff);
  397. val >>= 8;
  398. }
  399. }
  400. void writeMetaData (const FlacNamespace::FLAC__StreamMetadata* metadata)
  401. {
  402. using namespace FlacNamespace;
  403. auto& info = metadata->data.stream_info;
  404. unsigned char buffer[FLAC__STREAM_METADATA_STREAMINFO_LENGTH];
  405. const unsigned int channelsMinus1 = info.channels - 1;
  406. const unsigned int bitsMinus1 = info.bits_per_sample - 1;
  407. packUint32 (info.min_blocksize, buffer, 2);
  408. packUint32 (info.max_blocksize, buffer + 2, 2);
  409. packUint32 (info.min_framesize, buffer + 4, 3);
  410. packUint32 (info.max_framesize, buffer + 7, 3);
  411. buffer[10] = (uint8) ((info.sample_rate >> 12) & 0xff);
  412. buffer[11] = (uint8) ((info.sample_rate >> 4) & 0xff);
  413. buffer[12] = (uint8) (((info.sample_rate & 0x0f) << 4) | (channelsMinus1 << 1) | (bitsMinus1 >> 4));
  414. buffer[13] = (FLAC__byte) (((bitsMinus1 & 0x0f) << 4) | (unsigned int) ((info.total_samples >> 32) & 0x0f));
  415. packUint32 ((FLAC__uint32) info.total_samples, buffer + 14, 4);
  416. memcpy (buffer + 18, info.md5sum, 16);
  417. const bool seekOk = output->setPosition (streamStartPos + 4);
  418. ignoreUnused (seekOk);
  419. // if this fails, you've given it an output stream that can't seek! It needs
  420. // to be able to seek back to write the header
  421. jassert (seekOk);
  422. output->writeIntBigEndian (FLAC__STREAM_METADATA_STREAMINFO_LENGTH);
  423. output->write (buffer, FLAC__STREAM_METADATA_STREAMINFO_LENGTH);
  424. }
  425. //==============================================================================
  426. static FlacNamespace::FLAC__StreamEncoderWriteStatus encodeWriteCallback (const FlacNamespace::FLAC__StreamEncoder*,
  427. const FlacNamespace::FLAC__byte buffer[],
  428. size_t bytes,
  429. unsigned int /*samples*/,
  430. unsigned int /*current_frame*/,
  431. void* client_data)
  432. {
  433. return static_cast<FlacWriter*> (client_data)->writeData (buffer, (int) bytes)
  434. ? FlacNamespace::FLAC__STREAM_ENCODER_WRITE_STATUS_OK
  435. : FlacNamespace::FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
  436. }
  437. static FlacNamespace::FLAC__StreamEncoderSeekStatus encodeSeekCallback (const FlacNamespace::FLAC__StreamEncoder*, FlacNamespace::FLAC__uint64, void*)
  438. {
  439. return FlacNamespace::FLAC__STREAM_ENCODER_SEEK_STATUS_UNSUPPORTED;
  440. }
  441. static FlacNamespace::FLAC__StreamEncoderTellStatus encodeTellCallback (const FlacNamespace::FLAC__StreamEncoder*, FlacNamespace::FLAC__uint64* absolute_byte_offset, void* client_data)
  442. {
  443. if (client_data == nullptr)
  444. return FlacNamespace::FLAC__STREAM_ENCODER_TELL_STATUS_UNSUPPORTED;
  445. *absolute_byte_offset = (FlacNamespace::FLAC__uint64) static_cast<FlacWriter*> (client_data)->output->getPosition();
  446. return FlacNamespace::FLAC__STREAM_ENCODER_TELL_STATUS_OK;
  447. }
  448. static void encodeMetadataCallback (const FlacNamespace::FLAC__StreamEncoder*, const FlacNamespace::FLAC__StreamMetadata* metadata, void* client_data)
  449. {
  450. static_cast<FlacWriter*> (client_data)->writeMetaData (metadata);
  451. }
  452. bool ok = false;
  453. private:
  454. FlacNamespace::FLAC__StreamEncoder* encoder;
  455. int64 streamStartPos;
  456. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FlacWriter)
  457. };
  458. //==============================================================================
  459. FlacAudioFormat::FlacAudioFormat() : AudioFormat (flacFormatName, ".flac") {}
  460. FlacAudioFormat::~FlacAudioFormat() {}
  461. Array<int> FlacAudioFormat::getPossibleSampleRates()
  462. {
  463. return { 8000, 11025, 12000, 16000, 22050, 32000, 44100, 48000,
  464. 88200, 96000, 176400, 192000, 352800, 384000 };
  465. }
  466. Array<int> FlacAudioFormat::getPossibleBitDepths()
  467. {
  468. return { 16, 24 };
  469. }
  470. bool FlacAudioFormat::canDoStereo() { return true; }
  471. bool FlacAudioFormat::canDoMono() { return true; }
  472. bool FlacAudioFormat::isCompressed() { return true; }
  473. AudioFormatReader* FlacAudioFormat::createReaderFor (InputStream* in, const bool deleteStreamIfOpeningFails)
  474. {
  475. std::unique_ptr<FlacReader> r (new FlacReader (in));
  476. if (r->sampleRate > 0)
  477. return r.release();
  478. if (! deleteStreamIfOpeningFails)
  479. r->input = nullptr;
  480. return nullptr;
  481. }
  482. AudioFormatWriter* FlacAudioFormat::createWriterFor (OutputStream* out,
  483. double sampleRate,
  484. unsigned int numberOfChannels,
  485. int bitsPerSample,
  486. const StringPairArray& /*metadataValues*/,
  487. int qualityOptionIndex)
  488. {
  489. if (out != nullptr && getPossibleBitDepths().contains (bitsPerSample))
  490. {
  491. std::unique_ptr<FlacWriter> w (new FlacWriter (out, sampleRate, numberOfChannels,
  492. (uint32) bitsPerSample, qualityOptionIndex));
  493. if (w->ok)
  494. return w.release();
  495. }
  496. return nullptr;
  497. }
  498. StringArray FlacAudioFormat::getQualityOptions()
  499. {
  500. return { "0 (Fastest)", "1", "2", "3", "4", "5 (Default)","6", "7", "8 (Highest quality)" };
  501. }
  502. #endif
  503. } // namespace juce