You are not logged in or registered. Please login or register to use the full functionality of this board...
SIGN IN Join Our Community For FREE


Audio presentation of numbers as prime (=0) or first factor
09-20-2017, 12:30 AM (This post was last modified: 09-20-2017 12:47 AM by bplus.)
Post: #1
 (Print Post)
Audio presentation of numbers as prime (=0) or first factor
Code Snippet: [Select]
' Audio presentation of numbers.bas for QB64 fork (B+=MGA) 2017-09-20
' Using Owens 2X Deluxe Mod
_TITLE "Audio Presentation of Numbers as Primes = 0 or First Factor"
_DEFINE A-Z AS _INTEGER64
OPTION BASE 1
COMMON SHARED ff(), topN
topN = 1000000
testlimitN = SQR(topN)
DIM ff(topN + 30)
FOR i = 0 TO topN STEP 30
   ff(i + 2) = 2: ff(i + 3) = 3: ff(i + 4) = 2: ff(i + 5) = 5: ff(i + 6) = 2: ff(i + 8) = 2: ff(i + 9) = 3
   ff(i + 10) = 2: ff(i + 12) = 2: ff(i + 14) = 2: ff(i + 15) = 3: ff(i + 16) = 2: ff(i + 18) = 2
   ff(i + 20) = 2: ff(i + 21) = 3: ff(i + 22) = 2: ff(i + 24) = 2: ff(i + 25) = 5
   ff(i + 26) = 2: ff(i + 27) = 3: ff(i + 28) = 2: ff(i + 30) = 2
NEXT
ff(2) = 0: ff(3) = 0: ff(5) = 0
pattern(1) = 4: pattern(2) = 2: pattern(3) = 4: pattern(4) = 2
pattern(5) = 4: pattern(6) = 6: pattern(7) = 2: pattern(8) = 6
pcand = 7: patternI = 0
WHILE pcand < testlimitN
   IF ff(pcand) = 0 THEN
       i = pcand * pcand
       patternI2 = patternI
       DO
           IF ff(i) = 0 THEN ff(i) = pcand
           patternI2 = patternI2 + 1
           IF patternI2 = 9 THEN patternI2 = 1
           i = i + pattern(patternI2) * pcand
           IF i > topN THEN EXIT DO
       LOOP

   END IF
   patternI = patternI + 1
   IF patternI = 9 THEN patternI = 1
   pcand = pcand + pattern(patternI)
WEND
FOR i = 500000 TO topN
   CLS
   PRINT i, ff(i)
   IF ff(i) = 0 THEN SOUND 137, 2 ELSE SOUND 137 + ff(i) * 10, 2 - ff(i) * .001
   _LIMIT 5
NEXT


Append: Sped up and modulated:
Code Snippet: [Select]
FOR i = 2 TO topN
    CLS
    PRINT i, ff(i)
    IF ff(i) = 0 THEN SOUND 137, 2 ELSE SOUND 137 + (ff(i) MOD 30) * 10, 2 - ff(i) * .001
    _LIMIT 60
NEXT
Find all posts by this user
Like Post
09-20-2017, 03:58 AM
Post: #2
 (Print Post)
RE: Audio presentation of numbers as prime (=0) or first factor
It's pretty cool... but I don't think it will top the music charts...

J

May your journey be free of incident.

Live long and prosper.
Find all posts by this user
Like Post
09-20-2017, 12:08 PM
Post: #3
 (Print Post)
RE: Audio presentation of numbers as prime (=0) or first factor
Quote:
It's pretty cool... but I don't think it will top the music charts...

J
Wink maybe not on Earth...
Hey Johnno are you working on anything?
Find all posts by this user
Like Post
09-20-2017, 05:39 PM
Post: #4
 (Print Post)
RE: Audio presentation of numbers as prime (=0) or first factor
I'm trying to re-create the old "1945" game. But, I hesitate in trying using QB64, as I seem to have problems displaying loaded sprites. I can create a sprite, using the primitive graphics commands etc, then display them without a problem. But, using sprite (bmp, png) files, I always get an 'invalid handle'. Even though I use the 'exact' same format that is in the 'help', I still get an error. I am of the opinion that it not a filename issue or a file format issue but an internal issue with _putimage() and Linux and or 64 bit... On rare occasions I will get a 'c++ compilation error' (even when the file is empty... lol) but, as I said, that's rare...

The game itself is quite straight forward and simple in its appearance. I originally had 'the listing' written for Naalaa but had lost it after several hard drive failures... lol  But, other than that, no. I'm not working on much at all. I 'troll' the Forums several times a day, just to keep in touch, and to pick up ideas. It gets a little disheartening when there is no apparent activity on some sites... It makes it a bit hard to learn when there is no one around to answer questions... *sigh*  But, I digress, why do you ask? Have you something in mind? (gleefully rubbing hands together in expectation...)

Time for coffee... the grey cells need a kick start... lol

J

May your journey be free of incident.

Live long and prosper.
Find all posts by this user
Like Post
09-20-2017, 07:08 PM (This post was last modified: 09-20-2017 07:21 PM by bplus.)
Post: #5
 (Print Post)
RE: Audio presentation of numbers as prime (=0) or first factor
Does the filename have a space in it?

Oops this is wrong post for this reply and I am not allowed to delete post for some silly reason.

When you try to use putImage, does the file have spaces in the name? I have heard that Linux is picky that way.
Find all posts by this user
Like Post
09-20-2017, 08:15 PM
Post: #6
 (Print Post)
RE: Audio presentation of numbers as prime (=0) or first factor
Not 100% sure about the spaces. But, if there are any, I usually encase the filename in quotes. eg: "the dog.png". But no. As a rule I avoid using spaces. Sometimes I use an underscore instead.

I've posted the problem with Walter to see if he knows anything... It could be just me... lol

J

May your journey be free of incident.

Live long and prosper.
Find all posts by this user
Like Post



Forum Jump:


User(s) browsing this thread: 1 Guest(s)




QB64 Member Project - Isolation
QB64 Member Project - Pivot version two
QB64 Member Project - Pivet version one
QB64 Member Project - 9 Board
QB64 Member Project - RGB Color Wheel
QB64 Member Project - Amazon
QB64 Member Project - Score 4
QB64 Member Project - MAPTRIANGLE
QB64 Member Project - Blokus
QB64 Member Project - Overboard
QB64 Member Project - Red Scrolling LED Sign
QB64 Member Project - Bowditch curve
QB64 Member Project - Domain
QB64 Member Project - Line Thickness
QB64 Member Project - Splatter
QB64 Member Project - Kings Vallery version two
QB64 Member Project - Inside Moves
QB64 Member Project - STxAxTIC 3D World
QB64 Member Project - Rotating Background
QB64 Member Project - Qubic
QB64 Member Project - Spiro Roses
QB64 Member Project - Spinning Color Wheel
QB64 Member Project - Sabotage
QB64 Member Project - Othello
QB64 Member Project - Basic Dithering
QB64 Member Project - Swirl
QB64 Member Project - Connect Four
QB64 Member Project - Martin Fractals version three
QB64 Member Project - Foursight
QB64 Member Project - Dreamy Clock
QB64 Member Project - Martin Fractals version two
QB64 Member Project - Quarto
QB64 Member Project - Exit
QB64 Member Project - Color Triangles
QB64 Member Project - Input
QB64 Member Project - Rubix's Magic
QB64 Member Project - Martin Fractals version four
QB64 Member Project - Algeria Weather
QB64 Member Project - Full Color LED Sign
QB64 Member Project - Touche
QB64 Member Project - OpenGL Triangles
QB64 Member Project - Kings Court
QB64 Member Project - Martin Fractals version one
QB64 Member Project - Dakapo
QB64 Member Project - Color Rotating Text
QB64 Member Project - Kobolts Monopoly
QB64 Member Project - Kings Valley verion one
QB64 Member Project - Point Blank
QB64 Member Project - ARB Checkers