PSG Module (including Music Macro Language)

Share your advanced PureBasic knowledge/code with the community.
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: PSG Module (including Music Macro Language)

Post by Joris »

If I do activated the debugger these line appear when I start your source code with the second sample code paste below the Module source.
The program halts on the DisableDebugger line then...
[19:43:37] Waiting for executable to start...
[19:43:37] Executable type: Windows - x86 (32bit, Unicode)
[19:43:37] Executable started.
[19:43:37] [ERROR] PSG Module (including Music Macro Language).pb (Line: 71)
[19:43:37] [ERROR] Invalid memory access. (read error at address 143825308)
[19:43:48] The Program was killed.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: PSG Module (including Music Macro Language)

Post by wilbert »

Update Feb 11, 2015:
* Switched to mono buffers internally since I didn't use stereo output anyway.
* Added support for WMME; on Windows PortAudio isn't required anymore although you can still use it if you wish.
Windows (x64)
Raspberry Pi OS (Arm64)
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: PSG Module (including Music Macro Language)

Post by Joris »

The update works here.
(So it is really PortAudio that caused a problem.)
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5352
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: PSG Module (including Music Macro Language)

Post by Kwai chang caine »

The two version works great
Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: PSG Module (including Music Macro Language)

Post by wilbert »

@Joris,
Thanks for checking. I'm glad to hear this one is working on your computer.

@KCC,
Always good to hear something is working :)


A few more demo tunes ...

Code: Select all

UseModule PSG

OpenWindow(0, 0, 0, 200, 100, "PSG Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

bass.s = "T11 \16 O2 V44 W1 L4 V+CV-E8E8 <FA> <V+GV-B8B8> CE :"
chords.s = "T11 \8 O4 V44 W4 L8 CEG>C< <FA>CF <GB>DG CEG>C< :"
melody.s = "T11 O5 W4 L4 CEC<G> CEC2 CEC<G> CE16R16E16R16C2 CEC<G> CEC2 CEC<G> C<G16>R16E16R16C2 :"

PSG_PlayMML(bass, chords, melody)

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow

PSG_Terminate()

Code: Select all

UseModule PSG

OpenWindow(0, 0, 0, 200, 100, "PSG Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

bass.s = "T11 O1 V48 W1 \8 L8  G4B-B-G4B-B-  G4>E-E-<G4>E-E-<  A>CF4<A>CF4<  F4AAGB->D4<"
chords.s = "T11 O3 V42 W4 \2 L8  GB->D4<GB->D4<  GB->E-<B-GB->E-<B-  A>CF4<A>CF4<  FA>C<AGB->D4<"
melody1.s = "T11 O5 V44 W4 \1 L4 GG2G8F8 E-E-2E-8D8 CCCD E-2D2"
melody2.s = "B-B-2B-8A8 GG2G8F8 CCCD E-2D2"
melody3.s = "B-B-2B-8A8 GG2G8F8 ACFA G2D2"

channel0.s = bass + ":"
channel1.s = chords + ":"
channel2.s = melody1 + melody2 + melody1 + melody3 + ":"

PSG_PlayMML(channel0, channel1, channel2)

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow

PSG_Terminate()
Windows (x64)
Raspberry Pi OS (Arm64)
infratec
Always Here
Always Here
Posts: 6866
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PSG Module (including Music Macro Language)

Post by infratec »

Hi,

the second example failed sometimes with 'Array index out of bounds'
A short look shows that the event data can be -2.
So I modified the code a bit:

Code: Select all

  If Event = #MML_Event
    EvData = EventData()
    If EvData >= 0
      StartDrawing(CanvasOutput(0))
        Circle(100, 50, 10, Colors(EvData))
      StopDrawing()   
    EndIf
  EndIf
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: PSG Module (including Music Macro Language)

Post by wilbert »

infratec wrote:the second example failed sometimes with 'Array index out of bounds'
A short look shows that the event data can be -2.
Thanks for mentioning.
I updated the code. :)
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
mk-soft
Always Here
Always Here
Posts: 5387
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: PSG Module (including Music Macro Language)

Post by mk-soft »

Very cool :D

Works fine on Mac :wink:
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: PSG Module (including Music Macro Language)

Post by dobro »

excellent Thanks :)
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
xaby
User
User
Posts: 13
Joined: Tue May 15, 2007 12:41 pm
Location: Germany - Berlin

Re: PSG Module (including Music Macro Language)

Post by xaby »

Love you guys.

Does anybody know the SiON Project from Klei?
https://sites.google.com/site/sioncenter/example

The other question is, does anybody know, what with https://mmltalks.appspot.com is?
It was a great site for MML music, playing in the browser with the Flash API from SiON.

Best regards, xaby
xaby
User
User
Posts: 13
Joined: Tue May 15, 2007 12:41 pm
Location: Germany - Berlin

Re: PSG Module (including Music Macro Language)

Post by xaby »

I am still hoping, to find this code somehow without the ASM parts.
Or maybe if someone could translate these parts, that would be great.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5352
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: PSG Module (including Music Macro Language)

Post by Kwai chang caine »

Wilbert wrote:@KCC,
Always good to hear something is working
Excuse me, not see your answer and your new melody :oops:

Image

2015 => 2021 i'm not sure you read that, but thanks for this nices two new musics 8)
ImageThe happiness is a road...
Not a destination
spacebuddy
Enthusiast
Enthusiast
Posts: 347
Joined: Thu Jul 02, 2009 5:42 am

Re: PSG Module (including Music Macro Language)

Post by spacebuddy »

Wilbert,

Is there anyway to get this working on apple silicon (M1)?

Thanks
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: PSG Module (including Music Macro Language)

Post by wilbert »

spacebuddy wrote:Is there anyway to get this working on apple silicon (M1)?
I changed the import statement in the first post.
You can try again with that modified code.
Does that make a difference ?
Windows (x64)
Raspberry Pi OS (Arm64)
spacebuddy
Enthusiast
Enthusiast
Posts: 347
Joined: Thu Jul 02, 2009 5:42 am

Re: PSG Module (including Music Macro Language)

Post by spacebuddy »

Hi Wilbert,

Yes, it works perfectly now, thank you.

This is going to be perfect for a game I am working on :)

Thanks
Post Reply