Shop OBEX P1 Docs P2 Docs Learn Events
simpleSound - A simple to use sound engine for the P2 - Page 4 — Parallax Forums

simpleSound - A simple to use sound engine for the P2

124»

Comments

  • @Ahle2 said:
    That game is weird and at the same time considered one of the only good games for the system.

    The Nintendo 64 didn't have proper sound chip either, so "a lot" (well some) of the music is made with FastTracker 2. The funny thing is that the sound effects and music code had to run on the same processor (Reality Signal Processor) as the graphics engine. Sound, naturally, wasn't more important than graphics, so a lot of games sounded bad compared to the PS1 with its awesome sound chip.

    Yeah. PS1 of course can also stream redbook audio, so it certainly has better sound. The sound in the N64 Zelda games is just awesome though. Great music and ambient sounds. They even support Dolby Surround.

  • evanhevanh Posts: 15,187
    edited 2022-02-15 06:40

    Johannes,
    Here's a de-popping modification to the stereo init routine from reSound.spin2.

    PUB init(sysClock, mixingFrequency, forceHq, nrInputs_, leftPin, rightPin, commonEffectsMask, enableAttention, hubRegPtr) | lcal, rcal, lhigh, rhigh
    '
    ' Initialize reSound according to the parameters given in stereo mode
    '
        ' @sysClock          - The Parallax P2 system clock in Hz
        ' @mixingFrequency   - The mixing frequency that reSound should run at
        ' @forceHq           - This forces the sample period to be a multiple of 256 to enable the HQ PWM smart pin output mode
        ' @nrInputs          - The number of inputs buffers to process by the reSound mixer
        ' @leftPin           - The smart pin number that should output the left audio signal
        ' @rightPin          - The smart pin number that should output the right audio signal
        ' @commonEffectsMask - Sets wich common effects should be enabled, such as reverb, lowpass filter, etc
        ' @enableAttention   - Enable cog attention events
        ' @hubRegPtr         - A pointer to hub RAM where reSound should store its data (this memory chunk needs to be "big enough")
    '
    
      left := leftPin
      right := rightPin
    
      pinstart( leftPin, P_ADC_VIO | P_ADC, %00_1001, 0 )    ' Measure VIO rail
      pinstart( rightPin, P_ADC_VIO | P_ADC, %00_1001, 0 )
      waitms(1)
      lhigh := rdpin( leftPin )
      rhigh := rdpin( rightPin )
    
      wrpin( leftPin, P_ADC_GIO | P_ADC )    ' Measure GIO rail
      wrpin( rightPin, P_ADC_GIO | P_ADC )
      waitms(1)
      lcal := rdpin( leftPin )
      rcal := rdpin( rightPin )
    
      lcal += (lhigh - lcal) * 10 / 33    ' Calculate the centre 1.0 volt level
      rcal += (rhigh - rcal) * 10 / 33    ' Calculate the centre 1.0 volt level
    
      wrpin( leftPin, P_ADC_1X | P_ADC )    ' Slow slew up of pin, 1X input is 537 kR to VIO/2
      repeat until rdpin( leftPin ) > lcal
      wrpin( leftPin, P_ADC_1X | P_ADC | P_OE | P_LOW_10UA )    ' Slow slew down of pin
      repeat until rdpin( leftPin ) < lcal
      pinclear( leftPin )
    
      wrpin( rightPin, P_ADC_1X | P_ADC )    ' Slow slew up of pin, 1X input is 537 kR to VIO/2
      repeat until rdpin( rightPin ) > rcal
      wrpin( rightPin, P_ADC_1X | P_ADC | P_OE | P_LOW_10UA )    ' Slow slew down of pin
      repeat until rdpin( rightPin ) < rcal
      pinclear( rightPin )
    
      initExplicit(sysClock, mixingFrequency, forceHq, nrInputs_, 2, @left, commonEffectsMask, enableAttention, hubRegPtr)
    

    Update: Fix a cut-n-paste error
    Update: Reduce pauses to 1 ms, even 100 us would be fine.

  • Ahle2Ahle2 Posts: 1,178

    Nice evanh,

    I barely have any time or energy to fiddle around with these things at the moment. Being home with my youngest (1.5 year old (+ my 3.5 year old somedays)) child is a lot harder work than my real job as an embedded software developer.
    I have been thinking about a different approach to depopping. Totally untested! By pulse width modulating between input and output at some "high enough" frequency and "slowly" going from "mostly input" until reaching "only output" over "some time". It should be fairly simple to implement; No need for any measurements or calculations.

  • evanhevanh Posts: 15,187

    That'll be interesting experiment. Like a fade-in I presume.
    I'm limited to working with init only. I didn't have the patience to make sense of the inner workings of reSound.

  • evanhevanh Posts: 15,187
    edited 2022-03-05 03:42

    I haven't tried any rapid DAC switching yet but have instead been playing with the 10 uA pin drive logic output using PWM smartpin.

    It has a maybe surprisingly symmetrical switching speed between the P and N channel drivers. Pulse widths have to be a minimum, both high and low sides, of around 250 ns for linear response to kick in. Room temp is 22 °C.

Sign In or Register to comment.