Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- OPTION BASE 0
- DIM nod AS INTEGER ' number of delays
- nod = 100
- DIM delayLength(nod) AS LONG, delayCounter(nod) AS LONG, delayFeedback(nod) AS _FLOAT
- FOR d = 0 TO nod - 1
- delayLength(d) = 5000 * RND + 500
- NEXT d
- FOR d = 0 TO nod - 1
- delayFeedback(d) = 0.1 * RND + 0.8
- NEXT d
- DIM delayBuffer(nod, 65536) AS _FLOAT
- DIM outputCounter AS LONG, outputSample AS _FLOAT, outputSampleInt AS INTEGER, outputLength AS LONG
- outputLength = 88200 * 2
- DIM inputLength AS LONG, inputCounter AS LONG
- inputLength = 5000
- inputCounter = 0
- DIM inputBuffer(inputLength) AS _FLOAT
- OPEN "delayinput.txt" FOR INPUT AS #1
- d = 0
- WHILE NOT EOF(1)
- INPUT #1, inputBuffer(d)
- d = d + 1
- WEND
- CLOSE #1
- OPEN "delay.txt" FOR OUTPUT AS #1
- DO
- outputSample = 0
- FOR d = 0 TO nod - 1
- ' 1) delay outputs the current sample in the delay buffer
- outputSample = outputSample + delayBuffer(d, delayCounter(d))
- ' 2) current sample in the delay buffer is multiplied with the delay's internal feedback factor (0-1)
- delayBuffer(d, delayCounter(d)) = delayBuffer(d, delayCounter(d)) * delayFeedback(d)
- ' 3) input signal sample is added to teh current sample
- delayBuffer(d, delayCounter(d)) = delayBuffer(d, delayCounter(d)) + inputBuffer(inputCounter)
- ' 4) advance delayCounter by 1
- delayCounter(d) = delayCounter(d) + 1
- ' 5) if reach the end of the delayBuffer, go to the beginning
- IF delayCounter(d) = delayLength(d) THEN
- delayCounter(d) = 0
- ' 6) apply possible filter to the whole delay buffer here?
- END IF
- NEXT d
- inputCounter = inputCounter + 1
- IF inputCounter = inputLength THEN inputCounter = inputCounter - 1
- outputCounter = outputCounter + 1
- PRINT #1, outputSample
- LOOP UNTIL outputCounter = outputLength OR INP(96) = 1
- CLOSE #1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement