Author Topic: Beating heart  (Read 3290 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Beating heart
« on: November 22, 2020, 12:28:51 am »
This animation is modeled on the sound, unfortunately they go in and out of sequence. The while that they are in sequence is kinda nice.

* Beating Heart.zip (Filesize: 2.3 MB, Downloads: 168)

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Beating heart
« Reply #1 on: November 22, 2020, 07:27:01 am »
Fine, I'll replace this model of the human heart with whatever nonsense I had believed previously. Bplus md.

The real question is, as I loop this program - when does Dark Side of the Moon start up?
You're not done when it works, you're done when it's right.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Beating heart
« Reply #2 on: November 22, 2020, 11:12:32 am »
Quote
when does Dark Side of the Moon start up?

LOL, That would be something to animate!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Beating heart
« Reply #3 on: November 22, 2020, 07:12:39 pm »
Hi Bplus
watching at that heart beating you let me remember this https://www.youtube.com/watch?v=_ut11U4JupI. However IMHO the routine of reloading the loop is the bad kid that let loose the synchronization between images and sound.
Cool!
I's thinking about if was there a math formula for Flutter?
Programming isn't difficult, only it's  consuming time and coffee

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Beating heart
« Reply #4 on: November 23, 2020, 01:56:17 pm »
@bplus
to be more specific I have thought about the regular atrial flutter and its fine wood saw sound...
here references: https://en.wikipedia.org/wiki/Atrial_flutter
sorry i have found no soundfile... the online bots are too good for me I find tachicardia https://it.123rf.com/audio_157818545_sound-effects-of-a-rapid-palpitating-heart-easily-loopable.html
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Beating heart
« Reply #5 on: November 23, 2020, 07:34:33 pm »
OK @TempodiBasic

You can put this into same folder as zip that has the .wav sound file:
Code: QB64: [Select]
  1. _TITLE "Beating heart w sound #2" 'B+ 2019-02-16
  2. '2019-02-16 Beating Cardiod
  3. '2019-02-28 random magnify and beat, redder heart
  4. '2020-11-21 Beating heart w sound
  5.  
  6. ' Thanks to SoundBible for .wav file
  7. ' http://soundbible.com/2162-Human-Heartbeat.html
  8. '    About: Human heart beating loud and strong. could also be used to show someone is worried, afraid, or injured.
  9. '    Title: Human Heartbeat
  10. '    Uploaded: 4.24.17
  11. '    License: Attribution 3.0
  12. '    Recorded by Daniel Simion
  13. '    File Size: 2.52 MB
  14. '    Downloads: 174359
  15.  
  16. '2020-11-23 Inspired by heart animation from TempodiBasic link to Culture Club: Love is Love
  17. '  [youtube]https://www.youtube.com/watch?v=_ut11U4JupI[/youtube]    maybe play this while watching heartbeat?
  18.  
  19. CONST xmax = 800, ymax = 600, CX = xmax / 2, CY = ymax / 2 - 50 'screen stuff
  20. SCREEN _NEWIMAGE(xmax, ymax, 32)
  21. _DELAY .25
  22.  
  23. DIM border AS _UNSIGNED LONG ' for PAINT with loads diffent sets of red based colors
  24. border = _RGB32(100, 0, 55)
  25. prepPalette
  26. hb& = _SNDOPEN("heartbeat.wav") 'get the beat going
  27. ri = 1 ' reds index
  28. WHILE _KEYDOWN(27) = 0
  29.     CLS
  30.     IF LEN(INKEY$) THEN prepPalette: ri = 1
  31.     loopCount = loopCount + 1
  32.     SELECT CASE loopCount MOD 8
  33.         CASE 0: magnify = 2.5
  34.         CASE 1: magnify = 2.75
  35.             ri = ri - 1
  36.         CASE 2: magnify = 2.5
  37.         CASE 3: magnify = 3
  38.             ri = ri - 1
  39.         CASE 4: magnify = 2.5
  40.         CASE 5: magnify = 2.5
  41.         CASE 6: magnify = 2.5
  42.         CASE 7: magnify = 2.5
  43.     END SELECT
  44.     FOR m = 8 TO 1 STEP -1
  45.         FOR a = -_PI TO _PI STEP _PI(1 / 360)
  46.             x = CX + m * magnify * xCard(a)
  47.             y = CY - m * magnify * yCard(a)
  48.             IF a <> -_PI THEN
  49.                 LINE (x, y)-(lastx, lasty), border
  50.             END IF
  51.             lastx = x: lasty = y
  52.         NEXT
  53.         PAINT (CX + (m - .5) * magnify * xCard(_PI(.7)), CY - (m - .5) * magnify * yCard(_PI(.7))), reds(ri + (17 - m)), border
  54.     NEXT
  55.     ri = ri + 1
  56.     IF ri > 50 THEN ri = 1
  57.     _DISPLAY
  58.     _LIMIT 11.1
  59.  
  60. SUB prepPalette
  61.     FOR i = 0 TO 100
  62.         r = RND * 225 + 30
  63.         reds(i) = _RGB32(r, RND * .25 * r, RND * .25 * r)
  64.     NEXT
  65.  
  66. 'Reference and thanks to:
  67. ' http://mathworld.wolfram.com/HeartCurve.html
  68. ' find the 6th heart curve equations #7, 8
  69. FUNCTION xCard (t)
  70.     xCard = 16 * SIN(t) ^ 3
  71.  
  72. FUNCTION yCard (t)
  73.     yCard = 13 * COS(t) - 5 * COS(2 * t) - 2 * COS(3 * t) - COS(4 * t)
  74.  
  75.  

EDIT: added prepPalette SUB so you can press any key and change up the palette of reds.
« Last Edit: November 23, 2020, 11:29:54 pm by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Beating heart
« Reply #6 on: November 25, 2020, 11:54:46 am »
@bplus
it's loveable
Thanks
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Beating heart
« Reply #7 on: November 25, 2020, 05:14:59 pm »
I am sure there is easier / better way to do this besides redrawing everything all the time.

Oh I know! By February 14, 2021 Follow Your Heart, if the virus doesn't get me first.