///////////////////////////////////////////////////////
| 52 | |
| 53 | //////////////////////////////////////////////////////////// |
| 54 | bool OutputSoundFile::openFromFile(const std::filesystem::path& filename, |
| 55 | unsigned int sampleRate, |
| 56 | unsigned int channelCount, |
| 57 | const std::vector<SoundChannel>& channelMap) |
| 58 | { |
| 59 | // If the file is already open, first close it |
| 60 | close(); |
| 61 | |
| 62 | // Find a suitable writer for the file type |
| 63 | m_writer = SoundFileFactory::createWriterFromFilename(filename); |
| 64 | if (!m_writer) |
| 65 | { |
| 66 | // Error message generated in called function. |
| 67 | return false; |
| 68 | } |
| 69 | |
| 70 | // Pass the stream to the reader |
| 71 | if (!m_writer->open(filename, sampleRate, channelCount, channelMap)) |
| 72 | { |
| 73 | err() << "Failed to open output sound file from file (writer open failure)" << std::endl; |
| 74 | close(); |
| 75 | return false; |
| 76 | } |
| 77 | |
| 78 | return true; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | //////////////////////////////////////////////////////////// |