/* ----------------------------------------------------------------------------- This source file is part of OpenSpace3D For the latest info, see http://www.openspace3d.com Copyright (c) 2012 I-maginer This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, or go to http://www.gnu.org/copyleft/lesser.txt ----------------------------------------------------------------------------- */ typeof iVolume = I;; var bMuteState = 0;; fun deleteOb(inst)= set iVolume = 75; set bMuteState = 0; _AudioSetMasterVolume iVolume; 0;; fun cbSetVolume(inst, from, action, param, rep) = let atoi param -> vol in ( set bMuteState = if (vol > 0) then 0 else 1; _AudioSetMasterVolume vol; set iVolume = _AudioGetMasterVolume; ); 0;; fun cbMute(inst, from, action, param, rep) = if (bMuteState) then nil else ( set iVolume = _AudioGetMasterVolume; _AudioSetMasterVolume 0; set bMuteState = 1; ); 0;; fun cbUnMute(inst, from, action, param, rep) = if (!bMuteState) then nil else ( _AudioSetMasterVolume iVolume; set bMuteState = 0; ); 0;; fun cbIncrease(inst, from, action, param, rep) = let _AudioGetMasterVolume -> vol in let if ((atoi param) == nil) then 10 else atoi param -> acc in let vol + acc -> nvol in ( set bMuteState = if (nvol > 0) then 0 else 1; _AudioSetMasterVolume nvol; set iVolume = _AudioGetMasterVolume; ); 0;; fun cbDecrease(inst, from, action, param, rep) = let _AudioGetMasterVolume -> vol in let if ((atoi param) == nil) then 10 else atoi param -> acc in let vol - acc -> nvol in ( set bMuteState = if (nvol > 0) then 0 else 1; _AudioSetMasterVolume nvol; set iVolume = _AudioGetMasterVolume; ); 0;; fun cbGetVolume(inst, from, action, param, rep) = SendPluginEvent inst "Volume" (itoa _AudioGetMasterVolume) nil; 0;; fun newOb(inst)= let atoi (getPluginInstanceParam inst "volume") -> volume in let if volume == nil then 75 else volume -> volume in ( set iVolume = volume; _AudioSetMasterVolume iVolume; PluginRegisterAction inst "Set volume" @cbSetVolume; PluginRegisterAction inst "Mute" @cbMute; PluginRegisterAction inst "Unmute" @cbUnMute; PluginRegisterAction inst "Increase" @cbIncrease; PluginRegisterAction inst "Decrease" @cbDecrease; PluginRegisterAction inst "Get volume" @cbGetVolume; setPluginInstanceCbDel inst @deleteOb; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;