MCPcopy Create free account
hub / github.com/BambooTracker/BambooTracker / exportToS98

Method exportToS98

BambooTracker/bamboo_tracker.cpp:1913–1972  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1911}
1912
1913bool BambooTracker::exportToS98(io::BinaryContainer& container, int target, bool tagEnabled,
1914 const io::S98Tag& tag, int rate, ExportCancellCallback checkFunc)
1915{
1916 int tmpRate = opnaCtrl_->getRate();
1917 opnaCtrl_->setRate(rate);
1918 double dblIntrCnt = static_cast<double>(rate) / static_cast<double>(mod_->getTickFrequency());
1919 size_t intrCnt = static_cast<size_t>(dblIntrCnt);
1920 double intrCntDiff = dblIntrCnt - intrCnt;
1921 double intrCntRest = 0;
1922
1923 int loopOrder, loopStep;
1924 checkNextPositionOfLastStepAndStepSize(mod_->getSong(curSongNum_), loopOrder, loopStep);
1925 bool loopFlag = (loopOrder != -1);
1926 int endCnt = (loopOrder == -1) ? 0 : 1;
1927 bool tmpFollow = std::exchange(isFollowPlay_, false);
1928 uint32_t loopPoint = 0;
1929 auto exCntr = std::make_shared<chip::S98Logger>(target);
1930 opnaCtrl_->setExportContainer(exCntr);
1931 startPlayFromStart();
1932 assignSampleADPCMRawSamples();
1933 exCntr->forceMoveLoopPoint();
1934
1935 while (true) {
1936 exCntr->getData(); // Set wait counts
1937 if (!streamCountUp()) {
1938 if (checkFunc()) { // Update lambda function
1939 stopPlaySong();
1940 isFollowPlay_ = tmpFollow;
1941 opnaCtrl_->setRate(tmpRate);
1942 return false;
1943 }
1944
1945 int playOrder = playback_->getPlayingOrderNumber();
1946 int playStep = playback_->getPlayingStepNumber();
1947 if (playOrder == loopOrder && playStep == loopStep && !(endCnt--)) break;
1948
1949 if (loopFlag && loopOrder == playOrder && loopStep == playStep) {
1950 loopPoint = exCntr->setLoopPoint();
1951 }
1952 }
1953
1954 intrCntRest += intrCntDiff;
1955 size_t extraIntrCnt = static_cast<size_t>(intrCntRest);
1956 intrCntRest -= extraIntrCnt;
1957 exCntr->elapse(intrCnt + extraIntrCnt);
1958 }
1959
1960 opnaCtrl_->setExportContainer();
1961 stopPlaySong();
1962 isFollowPlay_ = tmpFollow;
1963 opnaCtrl_->setRate(tmpRate);
1964
1965 try {
1966 io::writeS98(container, target, exCntr->getData(), CHIP_CLOCK, static_cast<uint32_t>(rate),
1967 loopFlag, loopPoint, tagEnabled, tag);
1968 return true;
1969 } catch (...) {
1970 throw;

Callers 1

Calls 12

writeS98Function · 0.85
getTickFrequencyMethod · 0.80
setExportContainerMethod · 0.80
forceMoveLoopPointMethod · 0.80
getDataMethod · 0.80
setLoopPointMethod · 0.80
elapseMethod · 0.80
getRateMethod · 0.45
setRateMethod · 0.45
getPlayingOrderNumberMethod · 0.45
getPlayingStepNumberMethod · 0.45

Tested by

no test coverage detected