void GraffitiTab::SetupToolbar () { Save_ = Toolbar_->addAction (tr ("Save"), this, SLOT (save ())); Save_->setProperty ("ActionIcon", "document-save"); Save_->setShortcut (QString ("Ctrl+S")); Revert_ = Toolbar_->addAction (tr ("Revert"), this, SLOT (revert ())); Revert_->setProperty ("ActionIcon", "document-revert"); Toolbar_->addSeparator (); RenameFiles_ = Toolbar_->addAction (tr ("Rename files"), this, SLOT (renameFiles ())); RenameFiles_->setProperty ("ActionIcon", "edit-rename"); Toolbar_->addSeparator (); GetTags_ = Toolbar_->addAction (tr ("Fetch tags"), this, SLOT (fetchTags ())); GetTags_->setProperty ("ActionIcon", "download"); SplitCue_ = Toolbar_->addAction (tr ("Split CUE..."), this, SLOT (splitCue ())); SplitCue_->setProperty ("ActionIcon", "split"); SplitCue_->setEnabled (false); }
WavpackSource::WavpackSource(const WavpackModule &module, const std::wstring &path) : m_module(module) { char error[0x100]; static WavpackStreamReader reader32 = { wavpack::read, wavpack::tell32, wavpack::seek_abs32, wavpack::seek32, wavpack::pushback, wavpack::size32, wavpack::seekable, nullptr }; static WavpackStreamReader64 reader64 = { wavpack::read, nullptr, wavpack::tell, wavpack::seek_abs, wavpack::seek, wavpack::pushback, wavpack::size, wavpack::seekable, nullptr, nullptr }; m_fp = win32::fopen(path, L"rb"); try { m_cfp = win32::fopen(path + L"c", L"rb"); } catch(...) {} int flags = OPEN_TAGS | OPEN_NORMALIZE | OPEN_DSD_AS_PCM | (m_cfp.get() ? OPEN_WVC : 0); void *ra = reinterpret_cast<void*>(static_cast<intptr_t>(_fileno(m_fp.get()))); void *rc = m_cfp.get() ? reinterpret_cast<void*>(static_cast<intptr_t>(_fileno(m_cfp.get()))) : 0; WavpackContext *wpc = nullptr; if (m_module.OpenFileInputEx64) wpc = m_module.OpenFileInputEx64(&reader64, ra, rc, error, flags, 0); else wpc = m_module.OpenFileInputEx(&reader32, ra, rc, error, flags, 0); if (!wpc) throw std::runtime_error("WavpackOpenFileInputEx() failed"); m_wpc.reset(wpc, m_module.CloseFile); if (!parseWrapper()) { bool is_float = m_module.GetMode(wpc) & MODE_FLOAT; uint32_t flags = is_float ? kAudioFormatFlagIsFloat : kAudioFormatFlagIsSignedInteger; uint32_t bits = m_module.GetBitsPerSample(wpc); uint32_t obits = (is_float && bits == 16) ? 16 : 32; m_asbd = cautil::buildASBDForPCM2(m_module.GetSampleRate(wpc), m_module.GetNumChannels(wpc), bits, obits, flags); } if (m_asbd.mBytesPerFrame / m_asbd.mChannelsPerFrame == 2) m_readSamples = &WavpackSource::readSamples16; else m_readSamples = &WavpackSource::readSamples32; m_length = m_module.GetNumSamples64 ? m_module.GetNumSamples64(wpc) : m_module.GetNumSamples(wpc); unsigned mask = m_module.GetChannelMask(wpc); chanmap::getChannels(mask, &m_chanmap, m_asbd.mChannelsPerFrame); fetchTags(); }
TakSource::TakSource(const TakModule &module, const std::shared_ptr<FILE> &fp) : m_fp(fp), m_module(module) { static TakStreamIoInterfaceImpl io; TtakSSDOptions options = { tak_Cpu_Any, 0 }; void *ctx = reinterpret_cast<void*>(static_cast<intptr_t>(_fileno(fp.get()))); TtakSeekableStreamDecoder ssd = m_module.SSD_Create_FromStream(&io, ctx, &options, staticDamageCallback, this); if (!ssd) throw std::runtime_error("tak_SSD_Create_FromStream"); m_decoder = std::shared_ptr<void>(ssd, m_module.SSD_Destroy); Ttak_str_StreamInfo_V22 info = { 0 }; if (m_module.SSD_GetStreamInfo_V22) TRYTAK(m_module.SSD_GetStreamInfo_V22(ssd, &info)); else { Ttak_str_StreamInfo_V10 *p = reinterpret_cast<Ttak_str_StreamInfo_V10*>(&info); TRYTAK(m_module.SSD_GetStreamInfo(ssd, p)); } uint32_t type = info.Audio.SampleBits == 8 ? 0 : kAudioFormatFlagIsSignedInteger; uint32_t bits = info.Audio.HasExtension ? info.Audio.ValidBitsPerSample : info.Audio.SampleBits; m_asbd = cautil::buildASBDForPCM2(info.Audio.SampleRate, info.Audio.ChannelNum, bits, 32, kAudioFormatFlagIsSignedInteger); m_block_align = info.Audio.BlockSize; m_length = info.Sizes.SampleNum; if (info.Audio.HasExtension && info.Audio.HasSpeakerAssignment) { char *a = info.Audio.SpeakerAssignment; for (unsigned i = 0; i < 16 && a[i]; ++i) m_chanmap.push_back(a[i]); } try { fetchTags(); } catch (...) {} }