I have written a 24-bit pseudorandom noise generator for the FV-1. It is a little different than the one that Frank posted and uses fewer instructions.
It should run for over 8.5 minutes without repeating.
; 24 bit maximal period Galois LFSR
; Example by Jack Orman
; http://www.muzique.com
; March 5, 2015
; REG 0 : LFSR NOISE REGISTER
; REG 1 : OUTPUT BIT
;
EQU LFSR REG0
EQU TEMP REG1
;
; SEED THE LFSR WITH A NON-ZERO VALUE
SKP RUN,START
SOF 0,0.666 ; JUST TO ENSURE IT IS REALLY NON-ZERO
WRAX LFSR,0
;
;
START:
LDAX LFSR ; GET LFSR REGISTER
AND 0x000001 ; GET LSB OF THE NOISE REGISTER
WRAX TEMP,0 ; SAVE BIT
RDAX LFSR,0.5 ; GET LFSR REG AND SHIFT RIGHT 1 PLACE
AND 0x7FFFFF ; CLEAR MSB
WRAX LFSR,0 ; SAVE RESULT
LDAX TEMP ; GET THE OUTPUT BIT
SKP ZRO,SHFTZRO ; IF 0 THEN JUMP
; IF LSB WAS SET THEN PROCESS
CLR ; CLEAR ACC
LDAX LFSR ; GET THE SAVED LFSR
XOR 0xD80000 ; TOGGLE THE MASK BITS
WRAX LFSR,0 ; SAVE IT
;
SHFTZRO:
LDAX LFSR
WRAX DACL,0
For a REALLY long period before repeats, you could run a pair of these number generators and then combine the outputs in an alternating stop-and-go configuration to make the noise output.
@Digital Larry, it would rock to have a few options for noise generating in spin cad, also the SAH block would be a bit more useful if you could supply any trigger (noise trigger, noise sample, could get some reallllly nice granular chorus going)
Ive been mainly compiling loads of things in asm that I plan to port once I understand how to do the conversion into blocks and update my git. I have a bunch of potential blocks ready but still not sure I understand the process, or what questions to ask for clarification yet.
This noise generator has been so useful to me. Thank you so much Jack! I found a more efficient way to execute the same function that some of you may find useful. The benefits of this alternative method is that you only require one register (the LFSR reg) and that the new LFSR value is stored in the accumulator once the function has been computed. Remember to initialize the LFSR reg to a non-zero value on startup.