Re: [hatari-devel] Use correct white noise |

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]

*To*: hatari-devel@xxxxxxxxxxxxxxxxxxx*Subject*: Re: [hatari-devel] Use correct white noise*From*: David Savinkoff <dsavnkff@xxxxxxxxx>*Date*: Mon, 3 Sep 2012 14:56:31 -0600 (MDT)*Cc*: hatari-devel@xxxxxxxxxxxxxxxxxxx

On Thursday 30 August 2012 12:02, Nicolas Pomarède wrote: > Le 14/07/2012 22:01, David Savinkoff a crit : > > Hi, > > > > This patch uses the correct LFSR for the YM2149. The previous must > > have had a typo. currentNoise ^=YM2149_RndCompute() is corrected. > > BTW the noise doesn't sound different. > > > > The code is also optimized in Galois form. > > > > see: (also note 17 stage table at end) > > http://www.newwaveinstruments.com/resources/articles/m_sequence_linear_fe > >edback_shift_register_lfsr.htm > > > > > > David > > Hello > > sorry for the late reply, been quite busy lately. I will modifiy Hatari > with your patch as soon as I can (I have some changes to finish/push > before) > > Regarding the fact that it doesn't really change the perceived result, I > also noticed that some times ago while trying different random methods > (the one you sent is similar to the one used in MAME for example). Even > using the rand() function gives similar result. > > In the end as this is white noise, the only thing that really matters is > the period in reg6 and the frequency at which we compute a new value ; > as long as the pseudo-random function is close enough to randomness, > result is not really discernible. > > Nicolas Hi Nicolas, I saw your message about 20 minutes after you posted it, but couldn't reply because talking is more natural than typing. Sometimes I can have a conversation, but all that I can type is an ACK (acknowledge). :) I did some research and found: (1) Only one reference to the pseudo-random noise in the YM2149. Someone associated with MAME originally claimed the LFSR is 17 bits with taps at bits 17 and 15... MAME was later changed to a LFSR with taps at bits 17 and 14. I found an open source VHDL project that uses taps at bits 17 and 15 (so does Hatari), the VHDL code should be Corrected And Optimized. See http://www.fpgaarcade.com/resources/ym2149.zip (2) No data or proof exists that the YM2149 is even a 17 bit LFSR. If the YM2149 is a 17 bit LFSR, it probably has taps at bits 17 and 14 because this was a popular LFSR from the 1970's (National Semiconductor MM5837 / AMI S2688). *taps at bits 17 and 15 are '6-sigma erroneous', which exceeds the 2^17 possible possibilities. ;) (3) Synthesizer musicians of 70's and 80's did not like the sound of this digital noise source and preferred an analog noise source. (*4) It is possible to determine the LFSR in the YM2149. One must make a good recording of YM2149 white noise as a mono .WAV file (data). Then one must determine 1's and 0's by inspection, and type at least twice as many bits as the length of the LFSR into the python code below (34 minimum for 17 bit LFSR - try 64 bits). I modified the code by adding data comments at the end. *** Open Challenge: Determine the Characteristic Polynomial and provide your data, method and apparatus. The answer is Not at the back of the book, so you will have to try several different data strings to be certain of your answer. If this experiment is independently verified by a few different sources, it can be made official by consensus. Note that a 17 bit LFSR with taps at 17 and 14 will have the characteristic polynomial (x^17 + x^3 + 1). x^17 + x^3 + 1 = x^17 + x^3 + x^0 tap at 17-0 = 17 tap at 17-3 = 14 **** Python Code **** https://raw.github.com/bozhu/BMA/master/bma.py ********************* #!/usr/bin/env python """ Copyright (C) 2012 Bo Zhu http://about.bozhu.me Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ def Berlekamp_Massey_algorithm(sequence): N = len(sequence) s = sequence[:] for k in range(N): if s[k] == 1: break f = set([k + 1, 0]) # use a set to denote polynomial l = k + 1 g = set([0]) a = k b = 0 for n in range(k + 1, N): d = 0 for ele in f: d ^= s[ele + n - l] if d == 0: b += 1 else: if 2 * l > n: f ^= set([a - b + ele for ele in g]) b += 1 else: temp = f.copy() f = set([b - a + ele for ele in f]) ^ g l = n + 1 - l g = temp a = b b = n - l + 1 # output the polynomial def print_poly(polynomial): result = '' lis = sorted(polynomial, reverse=True) for i in lis: if i == 0: result += '1' else: result += 'x^%s' % str(i) if i != lis[-1]: result += ' + ' return result return (print_poly(f), l) if __name__ == '__main__': seq = (0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0) # seq = (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1) # seq = (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1) (poly, span) = Berlekamp_Massey_algorithm(seq) print 'The input sequence is %s.' % str(seq) print 'Its characteristic polynomial is (%s),' % poly, print 'and linear span is %d.' % span

**Follow-Ups**:**Re: [hatari-devel] Use correct white noise***From:*Nicolas Pomarède

**Messages sorted by:**[ date | thread ]- Prev by Date:
**Re: [hatari-devel] 68030 MMU work** - Next by Date:
**Re: [hatari-devel] Use correct white noise** - Previous by thread:
**Re: [hatari-devel] 68030 MMU work** - Next by thread:
**Re: [hatari-devel] Use correct white noise**

Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |