Notifications
Clear all

[Closed] Play a midi note within a Script

Hello everyone,
I’m trying to create a one-coul-say piano player (but no need to go that far). But that’s the idea. Having some button playing notes.

I already found something that is almost what I want, only problem the sound is really ugly (spoiler alert: it’s a beep)


[i]
try (destroydialog X ) catch ()
rollout X “” (
button b1 “” width:20 height:50 across:6
button b2 “” width:20 height:50
button b3 “” width:20 height:50
button b4 “” width:20 height:50
button b5 “” width:20 height:50
button b6 “” width:20 height:50

on x open do (

    global beepbeep =
    (
    source = ""
    source += "using System;


source += “using System.Runtime.InteropServices;

source += “class beepbeep

source += “{

source += ” [DllImport(“kernel32.dll”, SetLastError=true)]

source += ” public static extern bool Beep(uint dwFreq, uint dwDuration);

source += “}

    csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
    compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"

    compilerParams.GenerateInMemory = on
    compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(source)
    compilerResults.CompiledAssembly.CreateInstance "beepbeep"
    )

)



on b1 pressed do beepbeep.beep 65.4064 150
on b2 pressed do beepbeep.beep 69.2957 150
on b3 pressed do beepbeep.beep 73.4162 150
on b4 pressed do beepbeep.beep 77.7817  150
on b5 pressed do beepbeep.beep 82.4069  150
on b6 pressed do beepbeep.beep 87.3071  150

)
createDialog X pos:[100,100][/i]


So I guessed why not using windows-embeded-piano-midi-player.
That coul be fun!
Only thing is I have no idea how to do this.
Maybe refering to a C# object like in this script, yeah, but this is waayyyy above my grade.
Any idea?

Thanks!