### Recent Posts

Pages: [1] 2 3 4 5 6 7 8 ... 10
1
##### Purebasic / PB Twister
« Last post by Ampli on Yesterday at 07:41 PM »
Hello, I want to share my first code here with you. Nothing special but a huge step for me in coding.

Code: [Select]
`; Written by Mikael 'Ampli' Johansson 2019; Purebasic 5.71; Enjoy it as I do =) InitSprite()InitKeyboard()OpenWindow(1, 0,0,800,600,"DBF - Twister", #PB_Window_ScreenCentered)OpenWindowedScreen(WindowID(1),0,0,800,600,0,0,0)SetFrameRate(30)Global M_PI.f = 3.1415Repeat  ExamineKeyboard()  event = WindowEvent()  ClearScreen(RGB(55,155,185))    StartDrawing(ScreenOutput())    For x = 0 To 799 Step 2      aa.f  + 0.00015      s.f = Sin (aa+x / 150) * 120            amp.f = (Cos(x / 8000  ) * s/165)            y1.f = 300 + Cos((aa + amp)                   ) * 157      y2.f = 300 + Cos((aa + amp) + M_PI / 2        ) * 157      y3.f = 300 + Cos((aa + amp) + M_PI            ) * 157      y4.f = 300 + Cos((aa + amp) + M_PI + M_PI / 2 ) * 157            If y1 < y2        Line(x, y1+s, 1, y2 - y1, RGB(  127+s,   0,  127+s))        Line(x, y1+s, 9, y2 - y1 , RGB(  255,   255,  255))       EndIf       If y2 < y3         Line(x, y2+s, 1, y3 - y2, RGB(  127-s,   127-s,  0))         Line(x, y2+s, 9, y3 - y2 , RGB(  255,  255,  255))       EndIf       If y3 < y4         Line(x, y3+s, 1, y4 - y3, RGB(  127+s,   0,  100))         Line(x, y3+s, 9, y4 - y3 , RGB(  255,   255,  255))       EndIf       If y4 < y1         Line(x, y4+s, 1, y1 - y4, RGB(  0,   127+s,  75))         Line(x, y4+s, 9, y1 - y4 , RGB(  255,   255,  255))       EndIf    Next  StopDrawing()      Delay(1) : FlipBuffers()  Until event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)End`
2
##### General chat / Re: What are you working on at the moment?
« Last post by aNdy on Yesterday at 07:13 PM »
That underwater image is beautiful. Mysterious, but very pretty.
3
##### Projects / Re: New XM
« Last post by aNdy on Yesterday at 07:12 PM »
Nice!
4
##### General chat / Re: What are you working on at the moment?
« Last post by Rbz on August 18, 2019 »

5
##### Projects / Re: New XM
« Last post by Rbz on August 18, 2019 »
Very cool as always

If you want, I can upload it to Codigos site.
6
##### Purebasic / Re: Music Routing Problem
« Last post by Rbz on August 18, 2019 »
Seems to me that what you would need is to interpolate through v2m output data and send it to the shader, just a guess.
7
##### Projects / New XM
« Last post by Ampli on August 17, 2019 »
Hello, I having fun with Milkytracker again.
I don't know what to do with it so I post it here for you to hear.
More can be done to it but more songs have be started

/Ampli
8
##### Purebasic / Music Routing Problem
« Last post by inc. on August 06, 2019 »
Hi folks,

after a long time i'm back and have a question.
i wrote a demo code that show up a glsl shader and playing a v2m sound file.

how does it looks like (plain and simple)

after some fails i wanna explain the problem that i have.

If i'm sending the V2M Music Main Out to the Shader, that one of the white SinWave react to the Music nice and smoove does not work properly.

I tried a lot but always unnatural values will be sent to a SinWave and it wobble like this:

this is not what i want

define the value as following in Line 96:
Code: [Select]
`Change = MP_GetChannelVUV2M(channel, @left.f, @right.f)`
and adding the "change" into the shader code in Line 128 as an example:
Code: [Select]
`Fragment\$ + " float angle = iTime * speed * frequency *" + Change +"+(shift + uv.x) * 2.0;   " + Chr(10)`
i know there is anything missing in my thoughts.
maybe some one can help?

if you try to run the code properly, you need a PureBasic Version that support MP3D Lib because i used the v2m Lib that is included. Not to forget in Compiler Settings the LibSubsystem set to : dx9

Code: [Select]
`;:;:  PureBasic Version 5.43 LTS x86;:;:;:  get the MP3D Lib from here:;:  inc-games-design.de/Tools/Mp3dLib_installer.rar;:;:Enumeration  #MainEndEnumerationEnumeration  #leftbar  #rightbar  #Gad_OpenGL  #Exit_btn  #Gadget_exit  #textgadget  #Infobar_FontEndEnumeration#GL_VERTEX_SHADER = \$8B31#GL_FRAGMENT_SHADER = \$8B30#GL_BGR = \$80E0#GL_BGRA = \$80E1DataSection  Song:  IncludeBinary "Sound\mpl.v2m"  SongEnd:EndDataSection;:handle the GLSL needsXIncludeFile "include\cm_opengl_uni.pbi" : UseModule cm_openglDefine IsPlaying, EndOfTrackReached, EventGadgetDefine.i Event;:V2M Music File Main Out - left / rightDefine MainVULeft.f,MainVURight.f;:Channels V2M Music File - no need yetDefine Ch0VULeft.f, Ch0VURight.fDefine Ch1VULeft.f, Ch1VURight.fDefine Ch2VULeft.f, Ch2VURight.fDefine Ch3VULeft.f, Ch3VURight.fDefine Ch4VULeft.f, Ch4VURight.fDefine Ch5VULeft.f, Ch5VURight.fDefine Ch6VULeft.f, Ch6VURight.fDefine Ch7VULeft.f, Ch7VURight.fDefine Ch8VULeft.f, Ch8VURight.fDefine Ch9VULeft.f, Ch9VURight.fDefine Ch10VULeft.f, Ch10VURight.fDefine Ch11VULeft.f, Ch11VURight.fDefine Ch12VULeft.f, Ch12VURight.fDefine Ch13VULeft.f, Ch13VURight.fDefine Ch14VULeft.f, Ch14VURight.fDefine Ch15VULeft.f, Ch15VURight.fProcedure Open_MainScreen()    CreateImage(#Exit_btn,16,16)  StartDrawing(ImageOutput(#Exit_btn))  FillArea(1,1,-1,RGB(137,187,229))  Line(0,16,16,-17,RGB(45, 45, 45))  Line(0,0,16,16,RGB(45, 45, 45))  StopDrawing()  OpenWindow(#Main, 0 , 0, 640, 480,"",#PB_Window_ScreenCentered|#PB_Window_BorderLess|#PB_Window_Invisible)  SetWindowColor(#Main, RGB(137,187,229))  SetClassLongPtr_(WindowID(#Main), #GCL_STYLE, #CS_DROPSHADOW)  ;:exit button  ImageGadget(#Gadget_exit,WindowWidth(0)-22,2,16,16,ImageID(#Exit_btn))  TextGadget(#textgadget,5, 1, 567, 20, "GLSL Shader Test: inc 2019",#SS_CENTERIMAGE)  SetGadgetFont(#textgadget, LoadFont(#Infobar_Font, "Microsoft Sans Serif", 8, #PB_Font_HighQuality))  SetGadgetColor(#textgadget , #PB_Gadget_BackColor, RGB(137,187,229))   SetGadgetColor(#textgadget , #PB_Gadget_FrontColor, RGB(15, 15, 15))    OpenGLGadget(#Gad_OpenGL, 0, 20, 640, 460, #PB_OpenGL_Keyboard)  Init_OpenGL(#Gad_OpenGL, 640, 420)    HideWindow(#Main, #False)EndProcedureOpen_MainScreen()  MP_CatchV2M(?Song)  ;LOAD SONG  MP_PlayV2M(0)       ;0 START SOUND FROM THE BEGINNING             MP_SetVolumeV2M(1)  MP_GetMainVUV2M(@MainVULeft.f,@MainVURight.f)    ;channel = -1  ;Change = MP_GetChannelVUV2M(channel, @left.f, @right.f)      ;Change = MP_GetChannelVUV2M(channel, @MainVULeft.f, @MainVURight.f)  ;SetGadgetState(#ProgressBar_6,(Ch1VULeft + Ch1VURight)*20);:----------------------------------------------------------------------------------------  ;:The plain Shader Code  ;{Vertex\$ = "attribute vec3 position;"Vertex\$ + "attribute vec2 surfacePosAttrib;"Vertex\$ + "varying vec2 surfacePosition;"Vertex\$ + " void main() {"Vertex\$ + " surfacePosition = surfacePosAttrib;"Vertex\$ + " gl_Position = vec4( position, 1.0 );"Vertex\$ + " }"Fragment\$ = " #ifdef GL_ES                                                                       " + Chr(10)Fragment\$ + " precision mediump float;                                                           " + Chr(10)Fragment\$ + " #endif                                                                             " + Chr(10)Fragment\$ + " #extension GL_OES_standard_derivatives : enable                                   " + Chr(10)Fragment\$ + " uniform float time;                                                               " + Chr(10)Fragment\$ + " uniform vec2 mouse;                                                               " + Chr(10)Fragment\$ + " uniform vec2 resolution;                                                           " + Chr(10)Fragment\$ + " const vec3 top = vec3(0.318, 0.831, 1.0);                                         " + Chr(10)Fragment\$ + " const vec3 bottom = vec3(0.094, 0.141, 0.424);                                     " + Chr(10)Fragment\$ + " const float widthFactor = 1.5;                                                     " + Chr(10)Fragment\$ + " #define iTime time                                                                 " + Chr(10)Fragment\$ + " #define iResolution resolution                                                     " + Chr(10)Fragment\$ + " vec3 calcSine(vec2 uv, float speed,                                               " + Chr(10)Fragment\$ + " float frequency, float amplitude, float shift, float offset,                       " + Chr(10)Fragment\$ + " vec3 color, float width, float exponent, bool dir)                                 " + Chr(10)Fragment\$ + " {                                                                                 " + Chr(10)Fragment\$ + " float angle = iTime * speed * frequency *" + Change +"+(shift + uv.x) * 2.0;   " + Chr(10)Fragment\$ + " float y = sin(angle) * amplitude + offset;                                         " + Chr(10)Fragment\$ + " float clampY = clamp(0.0, y, y);                                                   " + Chr(10)Fragment\$ + " float diffY = y - uv.y;                                                           " + Chr(10)Fragment\$ + " float dsqr = distance(y, uv.y);                                                   " + Chr(10)Fragment\$ + " float scale = 1.0;                                                                 " + Chr(10)Fragment\$ + " if(dir && diffY > 0.0)                                                             " + Chr(10)Fragment\$ + " {                                                                                 " + Chr(10)Fragment\$ + " dsqr = dsqr * 4.0;                                                                 " + Chr(10)Fragment\$ + " }                                                                                 " + Chr(10)Fragment\$ + " else if(!dir && diffY < 0.0)                                                       " + Chr(10)Fragment\$ + " {                                                                                 " + Chr(10)Fragment\$ + " dsqr = dsqr * 4.0;                                                                 " + Chr(10)Fragment\$ + " }                                                                                 " + Chr(10)Fragment\$ + " scale = pow(smoothstep(width * widthFactor, 0.0, dsqr), exponent);                 " + Chr(10)Fragment\$ + " return min(color * scale, color);                                                 " + Chr(10)Fragment\$ + " }                                                                                 " + Chr(10)Fragment\$ + " void mainImage( out vec4 fragColor, in vec2 fragCoord )                           " + Chr(10)Fragment\$ + " {                                                                                 " + Chr(10)Fragment\$ + " vec2 uv = fragCoord.xy / iResolution.xy;                                           " + Chr(10)Fragment\$ + " vec3 color = vec3(mix(bottom, top, uv.y));                                         " + Chr(10)Fragment\$ + " color += calcSine(uv, 0.2, 0.20, 0.2, 0.0, 0.5,  vec3(0.3, 0.3, 0.3), 0.1, 15.0,false);    " + Chr(10)Fragment\$ + " color += calcSine(uv, 0.4, 0.40, 0.15, 0.0, 0.5, vec3(0.3, 0.3, 0.3), 0.1, 17.0,false); " + Chr(10)Fragment\$ + " color += calcSine(uv, 0.3, 0.60, 0.15, 0.0, 0.5, vec3(0.3, 0.3, 0.3), 0.05, 23.0,false); " + Chr(10)Fragment\$ + " color += calcSine(uv, 0.1, 0.26, 0.07, 0.0, 0.3, vec3(0.3, 0.3, 0.3), 0.1, 17.0,true); " + Chr(10)Fragment\$ + " color += calcSine(uv, 0.3, 0.36, 0.07, 0.0, 0.3, vec3(0.3, 0.3, 0.3), 0.1, 17.0,true); " + Chr(10)Fragment\$ + " color += calcSine(uv, 0.5, 0.46, 0.07, 0.0, 0.3, vec3(0.3, 0.3, 0.3), 0.05, 23.0,true); " + Chr(10)Fragment\$ + " color += calcSine(uv, 0.2, 0.58, 0.05, 0.0, 0.3, vec3(0.3, 0.3, 0.3), 0.2, 15.0,true); " + Chr(10)Fragment\$ + " fragColor = vec4(color,1.0);                                                       " + Chr(10)Fragment\$ + " }                                                                                 " + Chr(10)Fragment\$ + " void main( void ) {                                                               " + Chr(10)Fragment\$ + " mainImage(gl_FragColor, gl_FragCoord.xy);                                         " + Chr(10)Fragment\$ + " }                                                                                 " + Chr(10);}CreateShader(1, Vertex\$, Fragment\$)UseShader(1)Repeat   Event = WindowEvent()  EventGadget = EventGadget()    Render_OpenGL()  ;: LOOP FUNCTION V2M SOUND      If MP_IsPlayingV2M()      IsPlaying=1           ;CHECK IF SONG IS PLAYING    Else       EndOfTrackReached=1   ;IF SONG REACHED ITS END      MP_PlayV2M(0)         ;0 STARTs SONG At THE BEGINNING    EndIf    Select Event    Case #WM_LBUTTONDOWN      If WindowMouseX(#Main) >= 0 And WindowMouseX(#Main) <= 640 And WindowMouseY(#Main) >= 0 And WindowMouseY(#Main) <= 61        SendMessage_(WindowID(#Main), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)      EndIf    Case #PB_Event_Gadget      Select EventGadget()          Case #Gadget_exit          End      EndSelect  EndSelect  ;ESC END PROGRAM  If GetAsyncKeyState_(#VK_ESCAPE)    End  EndIfUntil Event = #PB_Event_CloseWindowEnd`
the complete package is attached to this posting.
9
##### Projects / Re: [C64 Music]
« Last post by aNdy on August 04, 2019 »
Very nice music tracks, specially liked the title track
Thank you!
10
##### Projects / Re: [C64 Music]
« Last post by Rbz on August 03, 2019 »
Very nice music tracks, specially liked the title track
Pages: [1] 2 3 4 5 6 7 8 ... 10