Author Topic: Sound  (Read 1874 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
Sound
« on: March 15, 2012, 05:57:15 AM »
Deleted
« Last Edit: April 11, 2015, 10:52:13 AM by Peter »

Charles Pegge

  • Guest
Re: Sound
« Reply #1 on: March 15, 2012, 12:30:38 PM »

Thanks Peter,

I am working with sound too. Using the low level wave audio API to synthesise sound effects. This enables sound to be generated in real time. There is a simple demo included in the latest Oxygen in-progress version:

examples/sound/WaveSynthDem.o2bas

A looping buffer is set up and may be fed with chunks of sound ahead of the play-position. about 740 words of audio data will required per 1/60 second per channel.

The buffer only has to be large enough to support the longest echoes and reverberation - say 5 seconds

Charles

Charles Pegge

  • Guest
Re: Sound
« Reply #2 on: March 16, 2012, 01:40:18 PM »
Hi Peter,

I could not resist playing with your Mandelbrot code

This is made a little simpler and optimised for speed:

Code: [Select]
include "win64.inc"
Window "MANDEL AFRICAN",620,500,4
sys_mode=4

single a,x,y,dy,cx,cy,i,b,yy,y0,x0,f
f=.04

ClsColor 105,168,100
For dy=0 To 2
   For x=0 To 620
      a = (x*.06)-12
      cx = -2 * a * f
      For y=0 To 255  
         yy = y + dy
         b = yy * .121 + 21
         cy = 2-b * f
         x0 = 0
         y0 = 0
         For i=1 To 128
            x1 = x0 * x0 - y0 * y0 + cx
            y0 = 2 * x0 * y0 + cy
            x0 = x1
            iF x0 * x0 + y0 * y0 >4
              Pixel x, yy,ColorRGB(i*.4,y,i*.6)
              Pixel x, 480-yy, ColorRGB(i*.4,y,i*.6)
              Exit For
            End iF
         Next              
      Next
   Next
Next
Pause
WinEnd



And this is the central part rewritten in float assembler:

Code: [Select]
include "win64.inc"
Window "MANDEL AFRICAN",620,500,4
sys_mode=4

single a,x,y,dy,cx,cy,b,yy,y0,x0,f,c,i
c=4
f=.04

ClsColor 105,168,100
For dy=0 To 2
   For x=0 To 620
      a = (x*.06)-12
      cx = -2 * a * f
      For y=0 To 255  
         yy = y + dy
         b = yy * .121 + 21
         cy = 2-b * f
         x0 = 0
         y0 = 0
         mov ecx,128
         (
            dec ecx : jl exit
            fld dword x0 : fmul st0
            fld dword y0 : fmul st0
            fsubp st1,st0
            fadd dword cx
            fld1 : fadd st0
            fmul dword x0
            fmul dword y0
            fadd dword cy
            fstp dword y0
            fst dword x0
            '
            fmul st0 'x0*x0
            fld dword y0 : fmul st0
            faddp st1,st0
            fld dword c '4
            fcomip
            fstp st0
            ja repeat
            mov i,ecx
            '
            Pixel x, yy,ColorRGB(i*.4,y,i*.6)
            Pixel x, 480-yy, ColorRGB(i*.4,y,i*.6)
         )              
      Next
   Next
Next
Pause
WinEnd


Charles
« Last Edit: March 16, 2012, 02:11:19 PM by Charles Pegge »