Welcome, Guest |
You have to register before you can post on our site.
|
Latest Threads |
лучшие песни медляки слуш...
Forum: Petr
Last Post: WillieTop
Today, 02:21 AM
» Replies: 0
» Views: 14
|
пинк слушать онлайн беспл...
Forum: SMcNeill
Last Post: WillieTop
Today, 02:20 AM
» Replies: 0
» Views: 15
|
скачать музыку российскую...
Forum: madscijr
Last Post: WillieTop
Today, 02:18 AM
» Replies: 0
» Views: 15
|
нежная музыка mp3 скачать
Forum: Keybone
Last Post: WillieTop
Today, 02:17 AM
» Replies: 0
» Views: 14
|
лучшая песня слушать онла...
Forum: bplus
Last Post: WillieTop
Today, 02:16 AM
» Replies: 0
» Views: 16
|
пикник слушать онлайн луч...
Forum: Spriggsy
Last Post: WillieTop
Today, 02:15 AM
» Replies: 0
» Views: 15
|
какая сейчас популярная м...
Forum: RhoSigma
Last Post: WillieTop
Today, 02:14 AM
» Replies: 0
» Views: 15
|
хит лета 2019 музыка на т...
Forum: Christmas Code
Last Post: WillieTop
Today, 02:12 AM
» Replies: 0
» Views: 15
|
бесплатная музыка mp3 рег...
Forum: Works in Progress
Last Post: WillieTop
Today, 02:11 AM
» Replies: 0
» Views: 15
|
лучшие хиты музыка 2018 2...
Forum: Utilities
Last Post: WillieTop
Today, 02:10 AM
» Replies: 0
» Views: 16
|
|
|
What am I doing wrong with _FreeImage? |
Posted by: PhilOfPerth - 02-24-2023, 12:48 AM - Forum: Help Me!
- Replies (4)
|
 |
I have written a small test using _loadimage and _FreeImage, and all goes well except when I try to clear the images (as I believe is necessary after using them).
I get an Illegal function call message at that point. Why is it so???
Code: (Select All) Screen _NewImage(1500, 800, 32)
GetGridSize:
Locate 15, 66
Print "Choose a grid size, 1 to 4 (for 12, 20, 30 or 42 tiles)"
Play move$
Getsize:
_KeyClear: k = 0
While k < 1
_Limit 30
k = _KeyHit
Wend
Select Case k
Case Is = 49
numtiles = 12 ' numtiles is number of tiles for that size grid
numcols = 3 ' numcols is number of columns in the grid
Case Is = 50
numtiles = 20
numcols = 5
Case Is = 51
numtiles = 30
numcols = 5
Case Is = 52
numtiles = 42
numcols = 7
Case Else
GoTo Getsize
End Select
DisplayTiles: '
numrows = numtiles / numcols ' set number of rows needed for the numtiles and numcols
Dim tiles(numtiles) As Long
For a = 1 To numtiles
tiles(a) = _LoadImage("RecPics/test.jpg", 32) ' set tiles array with numpics copies of test.jpg
Next
For a = 1 To numtiles / 2
_PutImage (60 * a, 60), tiles(a) ' display first half of tiles array
Next
For a = numtiles / 2 + 1 To numtiles
_PutImage (60 * (a - numtiles / 2), 120), tiles(a) ' display second half of tiles array
Next
Sleep 2
For a = 1 To numtiles
_FreeImage (a) ' free all of the images from memory
Next
Print "I get an error message here: Illegal function call line 45 (the _FreeImage line)"
Sleep
|
|
|
Limitation of function EXP() |
Posted by: BSpinoza - 02-22-2023, 11:26 AM - Forum: General Discussion
- Replies (13)
|
 |
Why is in QB64 a limitation of the function EXP ?
"EXP(numericExpression)
...
The numericExpression must be less than or equal to 88.02969 or an "overflow" error will occur."
In C a similar limitation is much higher.
(I need it to use the Planck's law to calculate the spectral density of the electromagnetic radiation at low temperatures.)
With my C program the Planck's law can be applied at a temperature of 1K, in QB64 not lower than 102 K!
|
|
|
ChatGPT |
Posted by: TerryRitchie - 02-21-2023, 11:51 PM - Forum: General Discussion
- Replies (47)
|
 |
I've been playing with ChatGPT. I asked it this question:
"write qb64 code that converts 3d coordinates to 2d screen coordinates"
This is what it produced:
Code: (Select All) SCREEN 12 'Set the screen mode to 640x480 16-color mode
CLS 'Clear the screen
' Set up the 3D coordinates of a cube
DIM x(8), y(8), z(8)
x(1) = -1: y(1) = -1: z(1) = 1
x(2) = 1: y(2) = -1: z(2) = 1
x(3) = 1: y(3) = 1: z(3) = 1
x(4) = -1: y(4) = 1: z(4) = 1
x(5) = -1: y(5) = -1: z(5) = -1
x(6) = 1: y(6) = -1: z(6) = -1
x(7) = 1: y(7) = 1: z(7) = -1
x(8) = -1: y(8) = 1: z(8) = -1
' Set up the camera position
cx = 0 ' Camera X coordinate
cy = 0 ' Camera Y coordinate
cz = -10 ' Camera Z coordinate
' Set up the projection parameters
near_plane = 1 ' Distance to near plane
far_plane = 100 ' Distance to far plane
fov = 90 ' Field of view in degrees
' Calculate the projection matrix
f = 1 / TAN(fov / 2 * PI / 180) ' Calculate focal length
a = f * 640 / 480 ' Calculate aspect ratio
proj_matrix(1, 1) = a: proj_matrix(2, 2) = f
proj_matrix(3, 3) = far_plane / (far_plane - near_plane)
proj_matrix(3, 4) = -far_plane * near_plane / (far_plane - near_plane)
proj_matrix(4, 3) = 1
' Apply the projection matrix to the 3D coordinates and convert to 2D screen coordinates
FOR i = 1 TO 8
' Apply the projection matrix
x_proj = x(i) * proj_matrix(1, 1) + y(i) * proj_matrix(2, 1) + z(i) * proj_matrix(3, 1) + proj_matrix(4, 1)
y_proj = x(i) * proj_matrix(1, 2) + y(i) * proj_matrix(2, 2) + z(i) * proj_matrix(3, 2) + proj_matrix(4, 2)
w_proj = x(i) * proj_matrix(1, 4) + y(i) * proj_matrix(2, 4) + z(i) * proj_matrix(3, 4) + proj_matrix(4, 4)
' Convert to 2D screen coordinates
x_screen = 320 + x_proj / w_proj * 320 ' Center the X coordinate and scale to screen size
y_screen = 240 - y_proj / w_proj * 240 ' Center the Y coordinate and flip the Y axis
' Draw a point on the screen at the converted coordinates
PSET (x_screen, y_screen), 15
NEXT i
' Wait for the user to press a key
DO
SLEEP
LOOP UNTIL INKEY$ <> ""
END
Any thoughts?
|
|
|
Compiler commands |
Posted by: eoredson - 02-21-2023, 06:16 AM - Forum: Help Me!
- Replies (3)
|
 |
Hi,
I have looked through the Wiki and commands and _commands but nowhere have I found a description for the $ compiler commands..
I am aware of $Dynamic, $Static and $Include compiler directives, but what I need to know are the $IF keywords and variables..
Thanks,
Erik.
|
|
|
SndStereoSave for PHOENIX |
Posted by: Petr - 02-20-2023, 07:05 PM - Forum: Petr
- Replies (4)
|
 |
Hi team.
How it goes? Here I've modified my audio save routine quite a bit, cheekily borrowing a few things from @a740g and after some trouble it seems to work as expected. It's the first version, it can only do stereo, it doesn't even have subsampling. I will add all this gradually. Just one question: 32 bit WAV sound. Is the type SINGLE used in WAV containers? Windows media player didn't really want to understand it and played like if you ride a bike on a road paved with cobblestones and sing along... (so I converted it to the LONG type and it plays cleanly). Does anyone know?
Code: (Select All) 'SndStereoSave by Petr for PHOENIX 3.5.0
Dim Song As Long
Song = _SndOpen("vi.mp3") ' Replace file name with your sound file
Dim As _MEM N
N = _MemSound(Song, 0)
'convert MP3 as WAV!
If SndChannels(Song) < 2 Then Print "Sorry, this is just for stereo (first version).": End
SndStereoSave N, "Test.wav" 'tested on WAV 16bit stereo, XM file (stereo), MP3 (stereo), all pass
'create the same music as in Song, but so that it plays backwards. Lets try _SndNew!
'the same its for own music created in QB64
Select Case SNDGetBites(N)
Case 1, 2: bites& = 32
Case 3: bites& = 16
Case 4: bites& = 8
End Select
NM& = _SndNew(_SndLen(Song) * _SndRate, SndChannels(Song), bites&)
Dim Done As _Offset, PlusStep As _Offset, Value As Single, NewMusic As _MEM
NewMusic = _MemSound(NM&, 0)
Done = N.SIZE - N.ELEMENTSIZE
Do Until Done = 0
_MemGet N, N.OFFSET + Done, Value
_MemPut NewMusic, NewMusic.OFFSET + PlusStep, Value
Done = Done - 4
PlusStep = PlusStep + 4
Loop
SndStereoSave NewMusic, "Backward.wav"
_MemFree N
_MemFree NewMusic
End
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, ConvertOffset&& '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
Sub SndStereoSave (arr As _MEM, file As String)
Type head16
chunk As String * 4 ' 4 bytes (RIFF)
size As _Unsigned Long ' 4 bytes (file size) velikost souboru
fomat As String * 4 ' 4 bytes (WAVE)
sub1 As String * 4 ' 4 bytes (fmt )
subchunksize As Long ' 4 bytes (lo / hi), $00000010 for PCM audio
format As Integer ' 2 bytes (0001 = standard PCM, 0101 = IBM mu-law, 0102 = IBM a-law, 0103 = IBM AVC ADPCM)
channels As Integer ' 2 bytes (1 = mono, 2 = stereo)
rate As Long ' 4 bytes (sample rate, standard is 44100)
ByteRate As Long ' 4 bytes (= sample rate * number of channels * (bits per channel /8))
Block As Integer ' 2 bytes (block align = number of channels * bits per sample /8)
Bits As Integer ' 2 bytes (bits per sample. 8 = 8, 16 = 16)
subchunk2 As String * 4 ' 4 bytes ("data") contains begin audio samples
lenght As _Unsigned Long ' 4 bytes Data block size
End Type ' 44 bytes total
Dim H16 As head16
ch = FreeFile
H16.chunk = "RIFF"
H16.size = 44 + ConvertOffset(arr.SIZE)
H16.fomat = "WAVE"
H16.sub1 = "fmt "
H16.subchunksize = 16
H16.format = 1
H16.channels = 2
H16.rate = _SndRate
Select Case SNDGetBites(arr)
Case 1, 2: H16.Bits = 32
Case 3: H16.Bits = 16
Case 4: H16.Bits = 8
End Select
H16.ByteRate = (_SndRate * 2 * H16.Bits) / 8
H16.Block = (2 * H16.Bits) / 8
H16.subchunk2 = "data"
H16.lenght = ConvertOffset(arr.SIZE)
If _FileExists(file$) Then Kill file$
Audio$ = Space$(ConvertOffset(arr.SIZE))
If SNDGetBites(arr) = 1 Then 'convert values from SINGLE to LONG values, because Marena from the cowshed said it should be like that :) /Czech Joke/
Dim A As _MEM, VS As Single, VL As Long
A = _MemNew(arr.SIZE)
Do Until done& = arr.SIZE
VS = _MemGet(arr, arr.OFFSET + done&, Single)
VL& = 2147483648 * VS
_MemPut A, A.OFFSET + done&, VL&
done& = done& + 4
Loop
_MemGet A, A.OFFSET, Audio$
_MemFree A
Else
_MemGet arr, arr.OFFSET, Audio$
End If
Open file$ For Binary As #ch
Put #ch, , H16
Put #ch, , Audio$
Audio$ = ""
Close ch
End Sub
Function SNDGetBites (handle As _MEM)
Select Case handle.TYPE
Case 260: SNDGetBites = 1 ' 32-bit floating point SINGLE
Case 132: SNDGetBites = 2 ' 32-bit integer LONG
Case 130: SNDGetBites = 3 ' 16-bit integer INTEGER
Case 1153: SNDGetBites = 4 ' 8-bit unsigned integer
End Select
End Function
Function SndChannels~%% (handle As Long) 'work by a740g
Dim SampleData As _MEM
' Check if the sound is valid
SampleData = _MemSound(handle, 0)
If SampleData.SIZE = 0 Then
Print "SndChannels: MemSound return ZERO for audio data size!"
Exit Function
End If
' Check the data type and then decide if the sound is stereo or mono
Select Case SampleData.TYPE
Case 260 ' 32-bit floating point
If SampleData.ELEMENTSIZE = 4 Then
SndChannels = 1
ElseIf SampleData.ELEMENTSIZE = 8 Then
SndChannels = 2
End If
Case 132 ' 32-bit integer
If SampleData.ELEMENTSIZE = 4 Then
SndChannels = 1
ElseIf SampleData.ELEMENTSIZE = 8 Then
SndChannels = 2
End If
Case 130: ' 16-bit integer
If SampleData.ELEMENTSIZE = 2 Then
SndChannels = 1
ElseIf SampleData.ELEMENTSIZE = 4 Then
SndChannels = 2
End If
Case 1153: ' 8-bit unsigned integer
If SampleData.ELEMENTSIZE = 1 Then
SndChannels = 1
ElseIf SampleData.ELEMENTSIZE = 2 Then
SndChannels = 2
End If
End Select
_MemFree SampleData
End Function
It is good! I was so focused on functionality that I forgot to add labels to the program 
So - on line 4, enter a valid name for your music file for Phoenix and then run it. The program is stingy with words, it doesn't write anything on your screen, it keeps secrets. 
Your music file will be saved in WAV format to the file test.wav and backward.wav, then play them to check the functionality. Backward.wav is saved vice versa, plays from the end to begin.
|
|
|
Sample of _LOADIMAGE change |
Posted by: SMcNeill - 02-20-2023, 05:46 PM - Forum: Programs
- Replies (1)
|
 |
Code: (Select All) $Unstable:Http
Screen _NewImage(800, 600, 32)
logo$ = "https://qb64phoenix.com/qb64wiki/resources/assets/peWikiLogo.png"
image$ = Download$(logo$, foo&)
imagehandle = _LoadImage(image$, 32, "memory")
_PutImage , imagehandle
' Content of the HTTP response is returned. The statusCode is also assigned.
Function Download$ (url As String, statusCode As Long)
h& = _OpenClient("HTTP:" + url)
statusCode = _StatusCode(h&)
While Not EOF(h&)
_Limit 60
Get #h&, , s$
content$ = content$ + s$
Wend
Close #h&
Download$ = content$
End Function
Note: This requires version 3.6 or above to run!
|
|
|
Stupid graphics experiment |
Posted by: mnrvovrfc - 02-20-2023, 07:38 AM - Forum: Programs
- Replies (1)
|
 |
I failed to come up with a quick example for the new third parameter of _LOADIMAGE(), didn't pay attention that the string is supposed to be just like one that could be loaded from JPEG, PNG, PCX etc. graphics file format. Enjoy this, it's my first successful experiment ever with _MEMCOPY. A good improvement is to change the palette, either as greyscale or along a cool gradient.
Code: (Select All) 'by mnrvovrfc 20-Feb-2023
DIM a$, b AS STRING * 256000
DIM AS INTEGER v, i, j
DIM AS LONG ascr, ctop, cbot
DIM amem AS _MEM, bmem AS _MEM
SCREEN _NEWIMAGE(640, 400, 256)
PRINT "Building screen, please wait..."
ctop = 1
cbot = 640 * 399 + 1
a$ = SPACE$(640)
b = SPACE$(256000)
FOR j = 1 TO 200
FOR i = 1 TO 640
IF i MOD 2 = 0 THEN
MID$(a$, i, 1) = CHR$(150 + v + (i MOD 56))
ELSE
MID$(a$, i, 1) = CHR$(v + (i MOD 16))
END IF
NEXT
MID$(b, ctop, 640) = a$
MID$(b, cbot, 640) = a$
ctop = ctop + 640
cbot = cbot - 640
v = v + 1
IF v >= 50 THEN v = 0
NEXT
bmem = _MEM(b)
ascr = _COPYIMAGE(0)
amem = _MEMIMAGE(ascr)
_MEMCOPY bmem, bmem.OFFSET, bmem.SIZE TO amem, amem.OFFSET
_MEMFREE bmem
SCREEN ascr
SLEEP
SCREEN 0
_MEMFREE amem
SYSTEM
|
|
|
QB64 Phoenix Edition v3.6.0 Released! |
Posted by: DSMan195276 - 02-20-2023, 03:23 AM - Forum: Announcements
- Replies (40)
|
 |
QB64 Phoenix Edition v3.6.0!
https://github.com/QB64-Phoenix-Edition/...tag/v3.6.0
Enhancements - #286 - Added support for opening image from memory using _LOADIMAGE() - @a740g, @mkilgore
- _LOADIMAGE() has a new optional requirements$ argument, similar to the string argument to _SNDOPEN():
- _LOADIMAGE(fileName$[, [mode&][, requirements$]])
- Providing "memory" in the requirements will cause _LOADIMAGE() to treat the contents of the fileName$ argument as an image file itself, rather than attempting to open a file.
Bug Fixes- #287, #296 - Fixed building QB64-PE on MacOS High Sierra - @mkilgore
- #288 - Add missing keywords to syntax highlighter - @SteveMcNeill
- #273, #295 - Timers will no longer take twice as long at program start - @mkilgore
- #293, #295 - A stopped timer will now correctly run when turned on if it expired while stopped - @mkilgore
- #294, #295 - On Windows, timers will now correctly trigger during SLEEP in $Console programs - @mkilgore
- #298, #300, #302, #308 - Several improvements to the IDE Wiki - @RhoSigma-QB64
- Improved handling of HTML Entity and UTF-8 characters used in the Wiki.
- Fully implemented local links. The help page navigation in the IDE is now practically the same as in the real Wiki.
- #301, #307 - Fix using DECLARE LIBRARY with a stripped .so file - @mkilgore
- #297, #306 - The -o flag will no longer strip the extension from the executable name - @mkilgore
- The extension .exe will still be removed when compiling on non-Windows platforms.
Full Changelog: v3.5.0...v3.6.0
|
|
|
|