Squares

General FreeBASIC programming questions.
Locked
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Squares

Post by dodicat »

Albert.
D.J.Peters has compiled static openGL libraries from a TinyGL project.
http://www.freebasic.net/forum/viewtopi ... 14&t=24909

I have used the five deck maverick code to test it out.
It has all your speech and scoring.
The Fonts are much better because I can use Comic sans.
Please download TinyGL and test out the Maverick.
You can adjust the Font to suit yourself, I just did it quickly.
It should run fine along with Windows.bi
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Squares

Post by Tourist Trap »

What do you think of this <square root> based sampler??
[edit] fixed first version

Code: Select all

'attempt to make some sampling

screenRes 760, 540, 32
color , rgb(185,195,105)
cls

const as integer    _maxInitialClass = 255

dim as integer  initialDataClassArray(1 to _maxInitialClass)
dim as ulong    initialColorDataArray(1 to _maxInitialClass)

for i as integer = 1 to _maxInitialClass
    initialDataClassArray(i) = i
    initialColorDataArray(i) = (cInt(@( initialDataClassArray(i) ))\8)
    '
    line (10, (i - 1)*2)-step(100, 2), _ 
    initialColorDataArray(i), _ 
    bf
next i

dim as integer  classLengthArray(any)
dim as integer  reducedDataArray(any)
dim as integer  dominant
dim as boolean  foundNewClass
dim as integer  newClassStart

for i as integer = 1 to _maxInitialClass
    foundNewClass = FALSE
    if sqr(i)=cInt(sqr(i)) and not foundNewClass then
        foundNewClass = TRUE
        newClassStart = i
        dominant = initialColorDataArray(i)
        redim preserve classLengthArray(ubound(classLengthArray) + 1)
        redim preserve reducedDataArray(ubound(reducedDataArray) + 1)
        reducedDataArray(ubound(reducedDataArray)) =  dominant
        classLengthArray(ubound(classLengthArray)) += 1
        do
            i += 1
            classLengthArray(ubound(classLengthArray)) += 1
        loop until sqr(i)=cInt(sqr(i))
        line (10 + 200, (newClassStart - 1)*2)- _ 
             step(100, 2*classLengthArray(ubound(classLengthArray))), _ 
             dominant, _
             bf
    else
        ''
    end if
    i -= 1
next i


getKey()
'(eof)
Other version:

Code: Select all

'attempt to make some function based sampling
#macro _SQRSAMPLEFUNCTION( arg )
    sqr( arg )
#endmacro

#macro _LOGSAMPLEFUNCTION( arg )
    log( arg )
#endmacro

#macro _CUSTOMSAMPLEFUNCTION( arg )
    log(exp(-arg + 100)  + exp( arg - 100))
#endmacro


screenRes 760, 540, 32
color , rgb(185,195,105)
cls

const as integer    _maxInitialClass = 255

dim as integer  initialDataClassArray(1 to _maxInitialClass)
dim as ulong    initialColorDataArray(1 to _maxInitialClass)

for i as integer = 1 to _maxInitialClass
    initialDataClassArray(i) = i
    initialColorDataArray(i) = sqr((cInt(@( initialDataClassArray(i) ))))^3
    '
    line (10, (i - 1)*2)-step(100, 2), _ 
    initialColorDataArray(i), _ 
    bf
next i

dim as integer t
dim as integer  classLengthArray(any)
dim as integer  reducedDataArray(any)
dim as integer  dominant
dim as boolean  foundNewClass
dim as integer  newClassStart


t = 1
for i as integer = 1 to _maxInitialClass
    foundNewClass = FALSE
    if _SQRSAMPLEFUNCTION(i)=cInt( _SQRSAMPLEFUNCTION(i) ) and not foundNewClass then
        foundNewClass = TRUE
        newClassStart = i
        dominant = initialColorDataArray(i)
        redim preserve classLengthArray(ubound(classLengthArray) + 1)
        redim preserve reducedDataArray(ubound(reducedDataArray) + 1)
        reducedDataArray(ubound(reducedDataArray)) =  dominant
        classLengthArray(ubound(classLengthArray)) += 1
        do
            i += 1
            classLengthArray(ubound(classLengthArray)) += 1
        loop until _SQRSAMPLEFUNCTION(i)=cInt(_SQRSAMPLEFUNCTION(i)) orElse i>_maxInitialClass
        line (10 + t*200, (newClassStart - 1)*2)- _ 
             step(100, 2*classLengthArray(ubound(classLengthArray))), _ 
             dominant, _
             bf
    else
        i += 1
        if i>=_maxInitialClass then exit for
    end if
    i -= 1
next i
draw string (10+ t*200, 520), "_SQRSAMPLEFUNCTION)


t = 2
for i as integer = 1 to _maxInitialClass
    foundNewClass = FALSE
    if _LOGSAMPLEFUNCTION(i)=cInt( _LOGSAMPLEFUNCTION(i) ) and not foundNewClass then
        foundNewClass = TRUE
        newClassStart = i
        dominant = initialColorDataArray(i)
        redim preserve classLengthArray(ubound(classLengthArray) + 1)
        redim preserve reducedDataArray(ubound(reducedDataArray) + 1)
        reducedDataArray(ubound(reducedDataArray)) =  dominant
        classLengthArray(ubound(classLengthArray)) += 1
        do
            i += 1
            classLengthArray(ubound(classLengthArray)) += 1
        loop until _LOGSAMPLEFUNCTION(i)=cInt(_LOGSAMPLEFUNCTION(i)) orElse i>_maxInitialClass
        line (10 + t*200, (newClassStart - 1)*2)- _ 
             step(100, 2*classLengthArray(ubound(classLengthArray))), _ 
             dominant, _
             bf
    else
        i += 1
        if i>=_maxInitialClass then exit for
    end if
    i -= 1
next i
draw string (10+ t*200, 520), "_LOGSAMPLEFUNCTION)


t = 3
for i as integer = 1 to _maxInitialClass
    foundNewClass = FALSE
    if _CUSTOMSAMPLEFUNCTION(i)=cInt( _CUSTOMSAMPLEFUNCTION(i) ) and not foundNewClass then
        foundNewClass = TRUE
        newClassStart = i
        dominant = initialColorDataArray(i)
        redim preserve classLengthArray(ubound(classLengthArray) + 1)
        redim preserve reducedDataArray(ubound(reducedDataArray) + 1)
        reducedDataArray(ubound(reducedDataArray)) =  dominant
        classLengthArray(ubound(classLengthArray)) += 1
        do
            i += 1
            classLengthArray(ubound(classLengthArray)) += 1
        loop until _CUSTOMSAMPLEFUNCTION(i)=cInt(_CUSTOMSAMPLEFUNCTION(i)) orElse i>_maxInitialClass
        line (10 + t*200, (newClassStart - 1)*2)- _ 
             step(100, 2*classLengthArray(ubound(classLengthArray))), _ 
             dominant, _
             bf
    else
        i += 1
        if i>=_maxInitialClass then exit for
    end if
    i -= 1
next i
draw string (10+ t*200, 520), "_CUSTOMSAMPLEFUNCTION"



getKey()
'(eof)
Other version, with many different entries, and their sampled result. Many different custom function do some different kind of stuff.

Code: Select all

'attempt to make some function based sampling
'different entries / different samplers

#macro _SQRSAMPLEFUNCTION( arg )
    sqr( arg )
#endmacro

#macro _LOGSAMPLEFUNCTION( arg )
    log( arg )
#endmacro

#macro _CUSTOMSAMPLEFUNCTION( arg )
    'log( arg - 100 )                                           ''remove last 100 item, replaced by last value
    'log(log((2^(arg*log( 1/arg )))))                           ''remove start
    'sqr( arg )^(arg*log( 1/arg ))                              ''zoom start
    'sqr(log(exp(-arg + 100)  + exp( arg - 100)) + 100)         ''regular
    'sqr(log(exp(-arg + 1000)  - exp( arg - 1000)))             ''simplified + remove start
    (arg^(arg*log( 1/(sqr(log(exp(-arg + 1000)  - exp( arg - 1000)))) ))) ''zoom start more
#endmacro


screenRes 760, 540, 32
color , rgb(185,195,105)
cls

const as integer    _maxInitialClass = 255

dim as integer  initialDataClassArray(1 to _maxInitialClass)
dim as ulong    initialColorDataArray(1 to _maxInitialClass)

dim as integer loopTest
do
        for i as integer = 1 to _maxInitialClass
            initialDataClassArray(i) = i
            select case loopTest
                case 0
                    initialColorDataArray(i) = 255*(cInt(@( initialDataClassArray(i) ))\8)
                case 1
                    initialColorDataArray(i) = sqr((cInt(@( initialDataClassArray(i) ))))^3
                case 2
                    initialColorDataArray(i) = rgb(rnd()*255, 255, 255)
                case 3
                    initialColorDataArray(i) = rgb(255*i, 255/i, 255 mod i)
            end select
            
            '
            line (10, (i - 1)*2)-step(100, 2), _ 
            initialColorDataArray(i), _ 
            bf
        next i
        
        dim as integer t
        dim as integer  classLengthArray(any)
        dim as integer  reducedDataArray(any)
        dim as integer  dominant
        dim as boolean  foundNewClass
        dim as integer  newClassStart
        
        
        t = 1
        for i as integer = 1 to _maxInitialClass
            foundNewClass = FALSE
            if _SQRSAMPLEFUNCTION(i)=cInt( _SQRSAMPLEFUNCTION(i) ) and not foundNewClass then
                foundNewClass = TRUE
                newClassStart = i
                dominant = initialColorDataArray(i)
                redim preserve classLengthArray(ubound(classLengthArray) + 1)
                redim preserve reducedDataArray(ubound(reducedDataArray) + 1)
                reducedDataArray(ubound(reducedDataArray)) =  dominant
                classLengthArray(ubound(classLengthArray)) += 1
                do
                    i += 1
                    classLengthArray(ubound(classLengthArray)) += 1
                loop until _SQRSAMPLEFUNCTION(i)=cInt(_SQRSAMPLEFUNCTION(i)) orElse i>_maxInitialClass
                line (10 + t*200, (newClassStart - 1)*2)- _ 
                     step(100, 2*classLengthArray(ubound(classLengthArray))), _ 
                     dominant, _
                     bf
            else
                i += 1
                if i>=_maxInitialClass then exit for
            end if
            i -= 1
        next i
        draw string (10+ t*200, 520), "_SQRSAMPLEFUNCTION)
        
        
        t = 2
        for i as integer = 1 to _maxInitialClass
            foundNewClass = FALSE
            if _LOGSAMPLEFUNCTION(i)=cInt( _LOGSAMPLEFUNCTION(i) ) and not foundNewClass then
                foundNewClass = TRUE
                newClassStart = i
                dominant = initialColorDataArray(i)
                redim preserve classLengthArray(ubound(classLengthArray) + 1)
                redim preserve reducedDataArray(ubound(reducedDataArray) + 1)
                reducedDataArray(ubound(reducedDataArray)) =  dominant
                classLengthArray(ubound(classLengthArray)) += 1
                do
                    i += 1
                    classLengthArray(ubound(classLengthArray)) += 1
                loop until _LOGSAMPLEFUNCTION(i)=cInt(_LOGSAMPLEFUNCTION(i)) orElse i>_maxInitialClass
                line (10 + t*200, (newClassStart - 1)*2)- _ 
                     step(100, 2*classLengthArray(ubound(classLengthArray))), _ 
                     dominant, _
                     bf
            else
                i += 1
                if i>=_maxInitialClass then exit for
            end if
            i -= 1
        next i
        draw string (10+ t*200, 520), "_LOGSAMPLEFUNCTION)
        
        
        t = 3
        for i as integer = 1 to _maxInitialClass
            foundNewClass = FALSE
            if _CUSTOMSAMPLEFUNCTION(i)=cInt( _CUSTOMSAMPLEFUNCTION(i) ) and not foundNewClass then
                foundNewClass = TRUE
                newClassStart = i
                dominant = initialColorDataArray(i)
                redim preserve classLengthArray(ubound(classLengthArray) + 1)
                redim preserve reducedDataArray(ubound(reducedDataArray) + 1)
                reducedDataArray(ubound(reducedDataArray)) =  dominant
                classLengthArray(ubound(classLengthArray)) += 1
                do
                    i += 1
                    classLengthArray(ubound(classLengthArray)) += 1
                loop until _CUSTOMSAMPLEFUNCTION(i)=cInt(_CUSTOMSAMPLEFUNCTION(i)) orElse i>_maxInitialClass
                line (10 + t*200, (newClassStart - 1)*2)- _ 
                     step(100, 2*classLengthArray(ubound(classLengthArray))), _ 
                     dominant, _
                     bf
            else
                i += 1
                if i>=_maxInitialClass then exit for
            end if
            i -= 1
        next i
        draw string (10+ t*200, 520), "_CUSTOMSAMPLEFUNCTION"
        
        sleep
        loopTest += 1
loop until loopTest>=4


getKey()
'(eof)
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

I got an email yesterday from http://www.paramountsong.com

They are working on writing the music for my Christmas Carol "All For Me" , the demo should be out to the record labels in a couple weeks or so..

Its going to be a hit song like "Jingle Bells" and "Silent Night"

It will outlive me by hundreds of years unless they cancel christmas before then.
I heard a voice in the wind saying it would get a Grammy and gold record and then platinum.

If you do write or want to write songs , then follow this:

( Genre = ??? ) (Pop , Rock&roll , gospel , blues , light rock , etc..)
( Title = ??? )

lyrics
lyrics

email address
mailing address


If you don't get a recording contract in the mail after 10-15 days or so , then your lyrics didn't get accepted..
(they don't tell you if your lyrics suck , they just dont respond at all)
So then your got to morph/change your lyrics and re-submit them until you get an email..
(that's what i do , some of my songs are at version 4 till they got accepted.)
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Squares

Post by Tourist Trap »

albert wrote:I got an email yesterday from http://www.paramountsong.com

They are working on writing the music for my Christmas Carol "All For Me" , the demo should be out to the record labels in a couple weeks or so..

Its going to be a hit song like "Jingle Bells" and "Silent Night"
You'll finally get trillionare Albert ;-) Good job!
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

I was wanting to sell my FB programs..
But most of my "GOOD" programs are mostly written by someone else like Dodicat or Richard or D.J.Peters or someone else but me.

But i'm always making up little jingles everday , about things i see , or things that happen..

like:

Theres a car going down the street , Theres a car going down the street
I'm on the sidewalk walking a beat , Theres a car going down the street

or:

asphault
street signs
red light green light

cruisin
list'ning
don't it feel right

So i take the jingles and try to turn them into full songs and then i submit them. to see if they get accepted.
So far i got 5 songs accepted and i have to pay them to write the music to make a "Demo" to pass to the record labels.
Hopefully all 5 songs will get on the radio.
The record labels only acccept full songs , sung to music , called a "Demo" , so everyone needs to make a "Demo" even if your a pro-lyricist.
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Squares

Post by Tourist Trap »

albert wrote: But i'm always making up little jingles everday
Do you know this success, Clementine. In the mountain, in the canyon.... and his daughter Clementie ;-) Nice one that I guess people wants to get on air on the radio.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Tourist Trap

I did a "Country" song called "Rodeo" that has a bull named "Clementine"

( Genre = Country )

( Title = Rodeo )

Its saturday and i'm doing fine
counting bucks on a rodeo nine
they pull the gate
the bulls running late
to get the prize
i got to go past eight

do , do , do do do do do
do , do , do do do do do

I'm on a bull named clementine
counting bucks on a rodeo nine
clementine is uh really fine
lot of champs in its bloodline
it can buck and spin on a dime
no other bull like clementine

do , do , do do do do do
do , do , do do do do do

its saturday and i'm doing fine
riding a bull named clementine
they pull the gate
the bulls running late
to get the prize
i got to go past eight

do , do , do do do do do
do , do , do do do do do

no other bull like clementine
i'm counting bucks on a rodeo nine

do , do , do do do do do
do , do , do do do do do

no other bull like clementine


albert_redditt@yahoo.com

Albert Redditt
315 W. Carrillo St. #104
Santa Barbara, Ca. 93101


I'm waiting for them to do the music for "All For Me" before i order the "Rodeo" , "Demo"
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Squares

Post by Tourist Trap »

albert wrote:I did a "Country" song called "Rodeo" that has a bull named "Clementine"
Sincerely, you are gifted, it sounds fun. Some people would have tried to post on a youtube channel alternatively? But yes if you don't provide the banjo with it it will be less impressive of course.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Tourist Trap

I was a month to late for country singer George Strait , he got his songs from paramount in June and i did "Rodeo" in July.

I came up with a way to square a number using divides , ( num / ( 1 / num ) ) = num ^ 2
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Squares

Post by Tourist Trap »

albert wrote: I was a month to late for country singer George Strait , he got his songs from paramount in June and i did "Rodeo" in July.
Country music is funny. We have a meeting near where I leave in france where we can eat american buffalo (what amerindians used to eat) listen to country song and drive some jeeps ;-)
Unfortunately I'm now a little far of all this now.
[/quote]
albert wrote: I came up with a way to square a number using divides , ( num / ( 1 / num ) ) = num ^ 2
The question is what happens if you reiterate:
(num / ( 1 / (num / (1 / num ) ) ) )
More involved is what if you apply a little perturbation on the denominators:
(num / ( 1 / (num + e / (1 / num + e) ) ) ) with e = 1/num and num a big number, so e is actually certified to be small...
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Dodicat
@Tourist Trap

(Question) What does an Irish , 7 course dinner consist of ?

(Answer) A six-pack of beer and a potato...
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Squares

Post by Tourist Trap »

albert wrote:(Question) What does an Irish , 7 course dinner consist of ?

(Answer) A six-pack of beer and a potato...
I've add a friend of mines that has been in Irland, and that has confirmed this. However the beer is quite thick there, and probably can be taken for both food and drink.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

I just got an email from http://www.paramountsong.com

My christmas carol "All For Me" , the music is written , and now they're ready for the studio , to make the "DEMO"

After the studio , then it goes to the record labels , then i got to decide which record label gets it.. (Maybe hold an auction? "More For Me" )
Tourist Trap
Posts: 2958
Joined: Jun 02, 2015 16:24

Re: Squares

Post by Tourist Trap »

albert wrote:I just got an email from http://www.paramountsong.com

My christmas carol "All For Me" , the music is written , and now they're ready for the studio , to make the "DEMO"

After the studio , then it goes to the record labels , then i got to decide which record label gets it.. (Maybe hold an auction? "More For Me" )
Incredible. If they've written the music, they probably enjoy the song very much. Have listened the result?
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Squares

Post by albert »

@Dodicat
@Richard

How do you break a number into its different factors ?
Locked