PC speaker beep script

Hello,
Does anyone know how to script beeping with PC speaker instead of sound card? It could be useful as a render end notification.

PK

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jahman's picture

.

(dotnetclass "system.media.systemsounds").beep.play()

or

try (destroydialog X ) catch ()
 rollout X "" (
	spinner basefreq "frequency:" range:[1,1e6,500] type:#integer align:#center
	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;\n"
		source += "using System.Runtime.InteropServices;\n"
		source += "class beepbeep\n"
		source += "{\n"
		source += "	[DllImport(\"kernel32.dll\", SetLastError=true)]\n"
		source += "	public static extern bool Beep(uint dwFreq, uint dwDuration);\n"
		source += "}\n"
 
		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 (basefreq.value) 100
	on b2 pressed do beepbeep.beep (basefreq.value*2) 100
	on b3 pressed do beepbeep.beep (basefreq.value*3) 100
	on b4 pressed do beepbeep.beep (basefreq.value*4) 100
	on b5 pressed do beepbeep.beep (basefreq.value*5) 100
	on b6 pressed do beepbeep.beep (basefreq.value*6) 100
 
)
 createDialog X pos:[100,100]

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.