From b5c76a343b14c9743357bc294b098a40ce9f0d4b Mon Sep 17 00:00:00 2001 From: fredvs Date: Sat, 21 Nov 2020 05:19:12 +0100 Subject: [PATCH] Fixed playing reverse. --- src/songplayer.pas | 21 +++++++---- src/strumpract.prj | 94 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 78 insertions(+), 37 deletions(-) diff --git a/src/songplayer.pas b/src/songplayer.pas index 7e61ce3..426ab08 100644 --- a/src/songplayer.pas +++ b/src/songplayer.pas @@ -261,6 +261,7 @@ function DSPReverseBefore1(var Data: TuosF_Data; var fft: TuosF_FFT): TDArFloat; if (Data.position > Data.OutFrames div Data.channels) then uos_InputSeek(theplayer, InputIndex1, Data.position - (Data.OutFrames div Data.ratio)); + // writeln('position: ' + inttostr(Data.position)); end; function DSPReverseBefore2(var Data: TuosF_Data; var fft: TuosF_FFT): TDArFloat; @@ -268,7 +269,7 @@ function DSPReverseBefore2(var Data: TuosF_Data; var fft: TuosF_FFT): TDArFloat; if (Data.position > Data.OutFrames div Data.channels) then uos_InputSeek(theplayer2, InputIndex2, Data.position - (Data.OutFrames div Data.ratio)); -end; + end; function DSPReverseAfter(var Data: TuosF_Data; var fft: TuosF_FFT): TDArFloat; var @@ -276,17 +277,21 @@ function DSPReverseAfter(var Data: TuosF_Data; var fft: TuosF_FFT): TDArFloat; lengthbuf: integer; arfl: TDArFloat; begin - lengthbuf := length(Data.Buffer); - + lengthbuf := length(Data.Buffer) div 2; + if (Data.position > lengthbuf div Data.channels) then begin SetLength(arfl, lengthbuf); x := 0; - - while x < lengthbuf - 1 do - begin - arfl[x] := Data.Buffer[lengthbuf - x]; - arfl[x + 1] := Data.Buffer[lengthbuf - x - 1]; + { + writeln('length buff: ' + inttostr(lengthbuf)); + writeln('length OutFrames: ' + inttostr(Data.OutFrames)); + writeln('length ratio: ' + inttostr(Data.ratio)); + } + while x < lengthbuf do + begin + arfl[x] := Data.Buffer[lengthbuf - x -1]; + arfl[x + 1] := Data.Buffer[lengthbuf - x - 2]; Inc(x, 2); end; Result := arfl; diff --git a/src/strumpract.prj b/src/strumpract.prj index f34d73e..f73a03d 100644 --- a/src/strumpract.prj +++ b/src/strumpract.prj @@ -311,7 +311,7 @@ options=114 value= [projectoptionsfo.makegroupbox] firsttab=0 - index=0 + index=2 [projectoptionsfo.exceptionsgrid] propcolwidthref=758 width0=47 @@ -332,7 +332,7 @@ options=114 index=0 [projectoptionsfo.setting_tab] firsttab=0 - index=1 + index=2 [projectoptionsfo] stackedunder= x=188 @@ -842,9 +842,12 @@ settingsstorage=0 settingsprojecttree=0 settingsautoload=0 settingsautosave=0 -modulenames=0 -moduletypes=0 -modulefiles=0 +modulenames=1 + SONGPLAYERFO +moduletypes=1 + TSONGPLAYERFO +modulefiles=1 + /home/fred/strumpract/src/songplayer.mfm befcommandon=0 makeoptionson=12 4095 @@ -1204,7 +1207,7 @@ line=33 184 5721 1600 - 1462 + 1467 284 319 529 @@ -1212,7 +1215,7 @@ line=33 773 785 701 - 1538 + 1543 209 1136 3572 @@ -1221,9 +1224,9 @@ line=33 747 1517 163 - 1466 + 1471 362 - 1702 + 1707 address=33 4606912 7398231 @@ -1607,8 +1610,9 @@ envvarons=0 [edit] hintwidth=314 hintheight=200 -finddtext=addfromf +finddtext=reverse findhistory=20 + reverse addfromf linkvol2 speccalc @@ -1621,7 +1625,6 @@ findhistory=20 initcheck namegen AddIntoDevOut - reverse tfacegreen timemix.Value timermix @@ -1630,40 +1633,54 @@ findhistory=20 initvolleft2 maxvolleft1 findoptions=1 -editpos=1 - 0,0 +editpos=3 + 0,-1073741823 + 0,290 + 0,-1073741823 bookmarks0=0 -sourcefiles=1 +bookmarks1=0 +bookmarks2=0 +sourcefiles=3 ${PROJECTDIR}/strumpract.pas -relpaths=1 + ${PROJECTDIR}/songplayer.pas + ${PROJECTDIR}/uos_flat.pas +relpaths=3 strumpract.pas -ismoduletexts=1 + songplayer.pas + uos_flat.pas +ismoduletexts=3 + 0 0 -modules=4 + 0 +modules=5 /home/fred/strumpract/src/main.mfm /home/fred/strumpract/src/commander.mfm /home/fred/strumpract/src/drums.mfm /home/fred/strumpract/src/recorder.mfm -moduleoptions=4 + /home/fred/strumpract/src/songplayer.mfm +moduleoptions=5 + 0 0 0 0 0 -visiblemodules=4 +visiblemodules=5 0 0 0 0 -nomenumodules=4 + 0 +nomenumodules=5 -1 -1 -1 -1 + 0 [sourcefo.files_tab] firsttab=0 -index=0 +index=1 [layout] -windowlayout=641 +windowlayout=660 [mainfo.basedock] splitdir=2 useroptions=268450944 @@ -1695,8 +1712,8 @@ windowlayout=641 ny=0 ncx=0 ncy=0 - x=494 - y=438 + x=846 + y=246 cx=497 cy=314 rcx=0 @@ -1808,7 +1825,7 @@ windowlayout=641 sortdescend1=0 sorted=0 col=0 - row=15 + row=12 rowheight=16 [stackfo] splitdir=0 @@ -2144,12 +2161,12 @@ windowlayout=641 [debuggerfo.edit_compiler] value=Pascal [debuggerfo.file_history] - value=/home/fred/strumpract/src/strumpract.pas + value=/home/fred/strumpract/src/songplayer.pas history=20 + /home/fred/strumpract/src/songplayer.pas /home/fred/strumpract/src/strumpract.pas /home/fred/strumpract/src/main.pas /home/fred/strumpract/src/commander.pas - /home/fred/strumpract/src/songplayer.pas /home/fred/strumpract/src/waveform.mfm /home/fred/strumpract/src/waveform.pas /home/fred/strumpract/src/filelistform.pas @@ -2188,7 +2205,7 @@ windowlayout=641 rcy=0 [sourcefo.files_tab] firsttab=0 - index=0 + index=1 [confideufo.fontname] value=stf_default [confideufo.usedefaulteditoroptions] @@ -2251,7 +2268,7 @@ windowlayout=641 [_mse_commanderfo_mse_] splitdir=0 useroptions=268451963 - stackedunder=confdebuggerfo + stackedunder=_mse_songplayerfo_mse_ parent= mdistate=3 nx=0 @@ -2305,6 +2322,25 @@ windowlayout=641 wsize=0 active=0 visible=0 + [_mse_songplayerfo_mse_] + splitdir=0 + useroptions=268451963 + stackedunder=confdebuggerfo + parent= + mdistate=3 + nx=0 + ny=0 + ncx=0 + ncy=0 + x=447 + y=62 + cx=452 + cy=128 + rcx=0 + rcy=0 + wsize=0 + active=0 + visible=0 [targetconsole] finddtext= findhistory=0