MCPcopy Create free account
hub / github.com/HertzDevil/0CC-FamiTracker / ExpandSample

Method ExpandSample

Source/SampleEditorView.cpp:302–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302void CSampleEditorView::ExpandSample(const ft0cc::doc::dpcm_sample &Sample, int Start) // // //
303{
304 // Expand DPCM to PCM
305 //
306
307 m_pSamples.reset();
308
309 if (Sample.size() == 0) {
310 m_iSize = 0;
311 m_iStartCursor = 0;
312 m_iSelStart = m_iSelEnd = -1;
313 return;
314 }
315
316 int Bytes = Sample.size() * 8;
317 m_pSamples = std::make_unique<int[]>(Bytes); // // //
318 m_iSize = Bytes;
319
320 const uint8_t *pData = Sample.data();
321 int Delta = Start;
322
323 for (int i = 0; i < Bytes; ++i) {
324 int BitPos = (i & 0x07);
325 if (pData[i >> 3] & (1 << BitPos)) {
326 if (Delta < 126)
327 Delta += 2;
328 }
329 else {
330 if (Delta > 1)
331 Delta -= 2;
332 }
333 m_pSamples[i] = Delta;
334 }
335
336 m_iSelStart = m_iSelEnd = -1;
337 m_iStartCursor = 0;
338
339 if (m_iViewEnd == 0) {
340 m_iViewStart = 0;
341 m_iViewEnd = m_iSize;
342 SetZoom(1.0f);
343 }
344
345 int ViewSize = m_iViewEnd - m_iViewStart;
346 if (m_iViewEnd > m_iSize) {
347 m_iViewEnd = m_iSize;
348 m_iViewStart = m_iSize - ViewSize;
349 if (m_iViewStart < 0) {
350 m_iViewStart = 0;
351 SetZoom(1.0f);
352 }
353 }
354}
355
356int CSampleEditorView::GetBlock(int Pixel) const
357{

Callers 1

UpdateSampleViewMethod · 0.80

Calls 3

resetMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected