Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some random goofy stuff just for fun
#1
Hi, this little program was made just for fun. It’s a small simulation of tuning an old analog TV. Using the + and – keys you simulate tuning. The goal was to blur or sharpen the picture depending on how “tuned in” it is, and also add noise to the audio. To run the program you’ll need one image and one MP3 file.

Code: (Select All)

imag = _LoadImage("masicko.jpg", 32)
snd = _SndOpen("01.mp3")

image = _NewImage(800, 600, 32)
_PutImage , imag, image
_FreeImage imag
Dim As Integer X, Y, W, H, R, nX, nY
W = _Width(image)
H = _Height(image)
Screen _NewImage(W, H, 32)
Dim arr(W - 1, H - 1) As _Unsigned Long
Dim arb(W - 1, H - 1) As _Unsigned Long

Dim As _MEM m, n, o, p, q
o = _MemImage(0)
m = _MemImage(image)
n = _Mem(arr())
p = _Mem(arb())
q = _MemSound(snd, 0)
_MemCopy m, m.OFFSET, m.SIZE To n, n.OFFSET
_MemFree m
_MemFree n


Dim SinPrecalc(179) As Single
Dim CosPrecalc(179) As Single

For f = 0 To 179
    SinPrecalc(f) = Sin(_D2R(f))
    CosPrecalc(f) = Cos(_D2R(f))
Next f



Dim As Single Le, Ri
SndPntr = 0
SndBuffEmpty = 1
Ra = 5
Do Until _KeyHit = 27
    X = 0
    Do Until X >= W - 1
        Y = 0
        i$ = InKey$
        If i$ = "+" Then Ra = Ra + 3
        If i$ = "-" Then Ra = Ra - 3
        Ra = _IIf(Ra < 1, 1, Ra)
        Do Until Y >= H - 1
            angle = Rnd * 179
            R = Rnd * Ra
            nX = X + CosPrecalc(angle) * R
            nY = Y + SinPrecalc(angle) * R



            Do While _SndRawLen < .01
                _MemGet q, q.OFFSET + SndP, Le
                SndP = SndP + 4
                _MemGet q, q.OFFSET + SndP, Ri
                SndP = SndP + 4
                SndP = _IIf(SndP > q.SIZE - 8, 0, SndP)
                noise = Ra / 50
                noise = _IIf(noise > 1, 1, noise)
                _SndRaw noise * Rnd + (1 - noise) * Le, noise * Rnd + (1 - noise) * Ri
            Loop

            nX = _IIf(nX > W - 1, W - 1, nX)
            nX = _IIf(nX < 0, 0, nX)
            nY = _IIf(nY > H - 1, H - 1, nY)
            nY = _IIf(nY < 0, 0, nY)
            arb(X, Y) = arr(nX, nY)
            Y = Y + 1
        Loop
        X = X + 1
    Loop
    _MemCopy p, p.OFFSET, p.SIZE To o, o.OFFSET
Loop

_MemFree o
_MemFree p
_FreeImage image
End


Reply


Messages In This Thread
Some random goofy stuff just for fun - by Petr - 12-02-2025, 08:52 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)