Page 1 of 1

Another Noise Generator

Posted: Sun Mar 08, 2015 4:36 pm
by amz-fx
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.

Code: Select all

; 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.

Best regards, Jack

Posted: Mon Mar 09, 2015 5:27 am
by Digital Larry
Thanks Jack! I'll see how this works out. It will be interesting to see if it works in my program's simulation mode.

DL

Posted: Sat Aug 06, 2016 12:41 pm
by MacroMachines
@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)

Posted: Sun Aug 07, 2016 6:18 am
by Digital Larry
Wait, I thought you were handling all block development from here on out!

:D

Posted: Sun Aug 14, 2016 8:40 am
by MacroMachines
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.

Re: Another Noise Generator

Posted: Thu Sep 24, 2020 1:51 am
by knutolai
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.

Code: Select all

ldax	LFSR		; Read LFSR reg 
AND	0x000001	; Get LSB of noise reg 
skp	ZRO, shiftzero	; if zero : don't toggle mask bits

clr			; clr acc (non-zero acc)
rdax	LFSR, 0.5		; Get LFSR, shift right 1 place
AND	0x7FFFFF		; Clear MSB
XOR	0xD80000	; Toggle MASK bits 

skp	NEG|GEZ, nwrite	; uncond. skp to storage
shiftzero:
rdax	LFSR, 0.5		; (acc = 0) Get LFSR, shift right 1 place
AND	0x7FFFFF		; Clear MSB
nwrite:
wrax	LFSR, 0		; store, clr