Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simulated Dancing Tesla Coil
#1
If you don't know already, a Tesla Coil is a metal rod that shoots out highly powered lightning bolts, which was invented by Nicola Tesla. This program is a simulation of that, where you tell it a .mp3 song to play and the lightning bolts jump around dancing to the song. There have been many real shows like this with real Tesla Coils, using music. 

This zip file also contains a small music album I created around 2005 or so and there's no lyrics, just electronic dance music I made using sound loops. 

Enjoy!

Edit: This zip removed to add the ability to use both 64 and 32 bit computers. The update is below.
Reply
#2
Hi SierraKen. It's a nicely done effect. I'm assuming you're using a 64-bit system, because a modest modification was needed in the 32-bit one:

Row 77:
Your: sz = _CV(_Unsigned _Integer64, _MK$(_Offset, SampleData.ELEMENTSIZE)) ' sz is the total size of the sound in bytes

Repaired by me: sz = ConvertOffset(SampleData.ELEMENTSIZE)

At the end the program i add ConvertOffset function downloaded from SMcNeill thread (the last one):

https://qb64phoenix.com/forum/showthread.php?tid=66

Nicely done music  Shy


Reply
#3
Thanks Petr! I'm glad you saw this! 

I tried your code with Steve's Function and got an error message in the Function. I also don't know how to use the Function with the variables it uses, so I'm just going to drop the 32 bit version (I use the 64 bit QB64), unless anyone wishes to tackle it. But thanks again!
Reply
#4
(08-17-2024, 04:56 PM)SierraKen Wrote: Thanks Petr! I'm glad you saw this! 

I tried your code with Steve's Function and got an error message in the Function. I also don't know how to use the Function with the variables it uses, so I'm just going to drop the 32 bit version (I use the 64 bit QB64), unless anyone wishes to tackle it. But thanks again!

This function?

Code: (Select All)
FUNCTION ConvertOffset&& (value AS _OFFSET)
$CHECKING:OFF
DIM m AS _MEM 'Define a memblock
m = _MEM(value) 'Point it to use value
$IF 64BIT THEN
   'On 64 bit OSes, an OFFSET is 8 bytes in size.  We can put it directly into an Integer64
   _MEMGET m, m.OFFSET,temp&&
    ConvertOffset&& = temp&& 'Get the contents of the memblock and put the values there directly into ConvertOffset&&
$ELSE
   'However, on 32 bit OSes, an OFFSET is only 4 bytes.  We need to put it into a LONG variable first
   _MEMGET m, m.OFFSET, temp& 'Like this
   ConvertOffset&& = temp& 'And then assign that long value to ConvertOffset&&
$END IF
_MEMFREE m 'Free the memblock
$CHECKING:ON
END FUNCTION

Just plug it in, and on lin 67, make it:
Code: (Select All)
sz = ConvertOffset(SampleData.ELEMENTSIZE)
Reply
#5
Thanks guys. I found the problem. It was using Explicit on the variables so DIM temp&& had to be added to the Function. So, hopefully this will run now on 32 bit computers. It works on my 64 bit. 

Here is the update.


Attached Files
.zip   Tesla Coil by SierraKen.zip (Size: 22.97 MB / Downloads: 24)
Reply
#6
I use the following. This is super fast as it just compiles to a C-style cast without any function calls.

Code: (Select All)
DECLARE LIBRARY
    $IF 64BIT THEN
        FUNCTION ConvertOffset~&& ALIAS "uintptr_t" (BYVAL p AS _UNSIGNED _OFFSET)
    $ELSE
        FUNCTION ConvertOffset~& ALIAS "uintptr_t" (BYVAL p AS _UNSIGNED _OFFSET)
    $END IF
END DECLARE
Reply
#7
(08-18-2024, 04:04 PM)SierraKen Wrote: Thanks guys. I found the problem. It was using Explicit on the variables so DIM temp&& had to be added to the Function. So, hopefully this will run now on 32 bit computers. It works on my 64 bit. 

Here is the update.

Nicely done! I am working on an audio visualization library and planning to include something like you did here as a vis option.
Reply
#8
Thanks a740g! I credit Petr for most of the work. Hopefully you can work with the basic part of it for your own needs.
Reply




Users browsing this thread: 6 Guest(s)