VirtualInstrumentManager mVIM = null; // The virtual instrument manager. //---------------------------------------------------------------------------- // Unity Functions //---------------------------------------------------------------------------- void Start() { // Get the button images. mButtonImages = new Sprite[3]; mButtonImages[0] = Resources.Load <Sprite>("Audio/Images/play_button"); mButtonImages[1] = Resources.Load <Sprite>("Audio/Images/pause_button"); mButtonImages[2] = Resources.Load <Sprite>("Audio/Images/stop_button"); // Get the virtual instrument manager. mVIM = GameObject.Find("VirtualInstrumentManager").GetComponent <VirtualInstrumentManager>(); // Set up the selection menu. mSongSelectionMenu = gameObject.GetComponent <Dropdown>(); mSongSelectionMenu.options.Clear(); mSongSelectionMenu.AddOptions(mVIM.SongManager.GetCombinedSongNames()); mSongSelectionMenu.AddOptions(mVIM.SongManager.GetMelodyNames()); mSongSelectionMenu.onValueChanged.AddListener(LoadDemoSong); // Load the default demo song. mSong = mVIM.SongManager.GetSongs()[0]; // Set up the play button mPlayButton = transform.GetChild(5).GetComponent <Button>(); mPlayButton.onClick.AddListener(OnPlayButtonClicked); // Set up the BPM slider. mBPMSlider = gameObject.transform.GetChild(4).GetComponent <Slider>(); mBPMSlider.value = mSong.GetBPM(); mBPMSlider.onValueChanged.AddListener(ChangeBPM); // Set up the BPM slider's label. mBPMSliderText = mBPMSlider.transform.GetChild(3).GetComponent <Text>(); mBPMSliderText.text = "BPM: " + mSong.GetBPM().ToString(); }
private VirtualInstrumentManager mVIM = null; //!< The @link VIM Virtual Instrument Manager@endlink. /*************************************************************************//** * @} * @defgroup SC_LSDUnity Unity Functions * @ingroup DocSC_LSD * These are functions automatically called by Unity * @{ ******************************************************************************/ /** * @brief Initializes the SC_LoadSongDialog by getting references to its components. */ private void Awake() { // Get the virtual instrument manager. mVIM = GameObject.Find("VirtualInstrumentManager").GetComponent <VirtualInstrumentManager>(); Assert.IsNotNull(mVIM, "Could not get a reference to the VirtualInstrumentManager!"); // Set up the event. SongSelected = new SongSelectedEvent(); // Set up the selection menu by getting a reference to it and clearing its options. Then, fill its options // with the songs in the SongManager. Also add its listener. mSongSelectionMenu = transform.GetChild(1).GetChild(0).GetComponent <Dropdown>(); mSongSelectionMenu.options.Clear(); mSongSelectionMenu.AddOptions(mVIM.SongManager.GetSongNames()); mSongSelectionMenu.onValueChanged.AddListener(OnSongSelected); // Get the default mSelectedSong = mVIM.SongManager.GetSongs()[0]; // Set up the buttons. mLoadButton = transform.GetChild(1).GetChild(2).GetComponent <Button>(); mLoadButton.onClick.AddListener(OnLoadButtonClicked); mCancelButton = transform.GetChild(1).GetChild(1).GetComponent <Button>(); mCancelButton.onClick.AddListener(OnCancelButtonClicked); }
// Update is called once per frame void Update() { // See if we need to load the audio. if (mVIM == null && EnableAudio) { // Load the prefab GameObject temp = Instantiate(Resources.Load <GameObject>(VIM_PATH)); Assert.IsNotNull(temp, "Failed to load VirtualInstrumentManagerPrefab!"); // Get the VIM from the prefab. temp.name = "VirtualInstrumentManager"; mVIM = temp.GetComponent <VirtualInstrumentManager>(); Assert.IsNotNull(mVIM, "Failed to get the VirtualInstrumentManager component!"); // Add the listener for note range changes. mVIM.ChangeNoteRange.AddListener(HandleChangeNoteRangeEvent); mVIM.PlaySong.AddListener(HandlePlaySongEvent); #if DEBUG_MUSICAL_TYPING // Disable Musical Typing mVIM.GetMusicalTypingHandler().MusicalTypingEnabled = false; #endif } // See if we need to unload the audio. else if (!EnableAudio && mVIM != null) { DestroyImmediate(mVIM.gameObject, false); mVIM = null; } }
private VirtualInstrumentManager mVIM = null; //!< The virtual instrument manager /*************************************************************************//** * @} * @defgroup SCMUnity Unity Functions * @ingroup DocSCM * These are functions called automatically by Unity. * @{ ******************************************************************************/ /** * @brief Initializes the @link DocSC Song Creation Interface@endlink by getting references to all of the modules within the scene. */ void Awake() { // Initialize the song. mSong = new Song(); // Get the virtual instrument manager. mVIM = GameObject.Find("VirtualInstrumentManager").GetComponent <VirtualInstrumentManager>(); // Set up the container for showing the song's notes. mNoteDisplay = gameObject.transform.GetChild(1).GetChild(0).GetChild(0).gameObject.AddComponent <SC_NoteDisplayContainer>(); // Set up the slider for the song's default BPM. mBPMSlider = gameObject.transform.GetChild(2).GetChild(2).gameObject.AddComponent <SC_InputFieldAndSlider>(); mBPMSlider.SetReferenceToInputField(transform.GetChild(2).GetChild(1).GetComponent <InputField>()); mBPMSlider.SetAsInt(true); mBPMSlider.ValueChanged.AddListener(OnBPMChange); // Set up the input field for naming the song. mSongNameInputField = gameObject.transform.GetChild(3).gameObject.GetComponent <InputField>(); mSongNameInputField.onEndEdit.AddListener(mSong.SetName); // Set up the buttons. mNewNoteButton = gameObject.transform.GetChild(5).GetChild(1).gameObject.GetComponent <Button>(); mNewNoteButton.onClick.AddListener(OnNewNoteButtonClicked); mSaveSongButton = gameObject.transform.GetChild(5).GetChild(2).gameObject.GetComponent <Button>(); mSaveSongButton.onClick.AddListener(OnSaveSong); mPlaySongButton = gameObject.transform.GetChild(5).GetChild(0).GetComponent <Button>(); mPlaySongButton.onClick.AddListener(OnPlaySong); mATIButton = gameObject.transform.GetChild(4).GetComponent <Button>(); mATIButton.onClick.AddListener(UnloadSongCreationInterface); mLoadSongButton = transform.GetChild(5).GetChild(3).GetComponent <Button>(); mLoadSongButton.onClick.AddListener(OnLoadSongButtonClicked); }
VirtualInstrumentManager mVIM = null; // The virtual instrument manager. //---------------------------------------------------------------------------- // Unity Functions //---------------------------------------------------------------------------- void Start() { // Get the button images. mButtonImages = new Sprite[3]; mButtonImages[0] = Resources.Load <Sprite>("Audio/Images/play_button"); mButtonImages[1] = Resources.Load <Sprite>("Audio/Images/pause_button"); mButtonImages[2] = Resources.Load <Sprite>("Audio/Images/stop_button"); // Get the virtual instrument manager. mVIM = GameObject.Find("VirtualInstrumentManager").GetComponent <VirtualInstrumentManager>(); // Account for the VIM changing instruments. mVIM.ChangeInstrument.AddListener(HandleInstrumentChange); // Set up the selection menu. mSongSelectionMenu = gameObject.GetComponent <Dropdown>(); mSongSelectionMenu.options.Clear(); if (!DrumLoopSelector) { mSongSelectionMenu.AddOptions(mVIM.SongManager.GetCombinedSongNames()); mSongSelectionMenu.AddOptions(mVIM.SongManager.GetMelodyNames()); mSongSelectionMenu.onValueChanged.AddListener(LoadDemoSong); // Load the default demo song. mSong = mVIM.SongManager.GetCombinedSongs()[0]; } else { mSongSelectionMenu.AddOptions(mVIM.SongManager.GetDrumLoopNames()); mSongSelectionMenu.onValueChanged.AddListener(LoadDemoSong); mSong = mVIM.SongManager.GetDrumLoops()[0]; } // Set up the play button. mPlayPauseButton = gameObject.transform.GetChild(5).GetChild(0).GetComponent <Button>(); mPlayPauseButton.onClick.AddListener(OnPlayPauseButtonClicked); // Set up the stop button mStopButton = gameObject.transform.GetChild(6).GetChild(0).GetComponent <Button>(); mStopButton.onClick.AddListener(OnStopButtonClicked); mStopButton.transform.parent.gameObject.SetActive(false); // Set up the BPM slider. mBPMSlider = gameObject.transform.GetChild(4).GetComponent <Slider>(); mBPMSlider.value = mSong.GetBPM(); mBPMSlider.onValueChanged.AddListener(ChangeBPM); // Set up the BPM slider's label. mBPMSliderText = mBPMSlider.transform.GetChild(3).GetComponent <Text>(); mBPMSliderText.text = "BPM: " + mSong.GetBPM().ToString(); // Add a listener for when the song is finished if needed. if (!DrumLoopSelector) { mVIM.AudioFinished.AddListener(SetFinished); } }
/** * @brief Sets the parent VirtualInstrumentManager and sets up diagnostics if needed. * @param[in] aVIM The parent VirtualInstrumentManager. */ public void SetVIM(VirtualInstrumentManager aVIM) { mVIM = aVIM; #if DEBUG_AUDIO_DIAGNOSTICS mDiagnosticsHandler = mVIM.GetDiagnosticsHandler(); mReported = false; #endif }
private VirtualInstrumentManager mVIM = null; //!< The parent VirtualInstrumentManager /** @} */ /*************************************************************************//** * @defgroup MusTypUnity Musical Typing Unity Functions * @ingroup MusTyp * Variables used to construct @link MusTyp Musical Typing@endlink events. ****************************************************************************/ /** @{ */ /** * @brief Initializes the MusicalTypingHandler by getting the parent VirtualInstrumentManager and calling SetMusicalTypingVariables. */ private void Awake() { // Get the Virtual Instrument Manager mVIM = gameObject.GetComponent <VirtualInstrumentManager>(); Assert.IsNotNull(mVIM, "Musical Typing couldn't get the VirtualInstrumentManager!"); // Set the default variables SetMusicalTypingVariables(); }
private void Start() { // Get the slider and add its listener. mSlider = gameObject.GetComponent <Slider>(); mSlider.onValueChanged.AddListener(OnSliderValueChanged); Assert.IsNotNull(mSlider, "Text/Slider handler could not find the slider!"); mVIM = GameObject.Find("VirtualInstrumentManager").GetComponent <VirtualInstrumentManager>(); Assert.IsNotNull(mVIM, "Text/Slider handler could not find the Virtual Instrument Manager!"); }
/*************************************************************************//** * @defgroup MarConstruct Constructors * @ingroup DocMar * These are functions that create a new instance of a Marimba. * @{ *****************************************************************************/ /** * @brief Creates a new Marimba instance. * @param[in] aParent The @link VIM Virtual Instrument Manager@endlink that will manage this instrument. * @return A newly created Marimba @link VI Virtual Instrument@endlink. */ public Marimba(VirtualInstrumentManager aParent) : base(aParent) { // Set default values mIsDrum = false; mLowestSupportedPitch = Music.PITCH.C2; mHighestSupportedPitch = Music.PITCH.C7; mNumSupportedPitches = 61; mSampleRate = 44100; mSampleInterval = 1f / mSampleRate; // Call functions to set the values relating to built-in dynamics, and create the filenames for each sample. InitializeBuiltInDynamics(); CreateFilenames(); // Set that this instrument is loaded. mLoaded = true; }
protected VirtualInstrumentManager mVIM = null; // The Virtual Instrument Manager. //---------------------------------------------------------------------------- // Unity Functions //---------------------------------------------------------------------------- // Initializes values. public void Start() { // Get the virtual instrument manager. mVIM = GameObject.Find("VirtualInstrumentManager").GetComponent <VirtualInstrumentManager>(); // Get the toggle switch and add its listener. mToggleSwitch = gameObject.transform.GetChild(0).GetComponent <Toggle>(); mToggleSwitch.onValueChanged.AddListener(OnToggle); // Get the toggle image. mToggleImage = mToggleSwitch.transform.GetChild(0).GetComponent <Image>(); // Load the images for the toggle switch. mButtonImages = new Sprite[2]; mButtonImages[0] = Resources.Load <Sprite>("Audio/Images/off_button"); mButtonImages[1] = Resources.Load <Sprite>("Audio/Images/on_button"); // Set the default parameters. SetDefaultParameters(); }
VirtualInstrumentManager mVIM = null; // The virtual instrument manager. #endif //---------------------------------------------------------------------------- // Unity Functions //---------------------------------------------------------------------------- // Use this for initialization void Start() { #if DEBUG && DEBUG_MUSICAL_TYPING mVIM = GameObject.Find("VirtualInstrumentManager").GetComponent <VirtualInstrumentManager>(); #endif }
protected VirtualInstrumentManager mParent; //!< The @link VIM manager@endlink for this instrument /*************************************************************************//** * @} * @defgroup VIBaseConstruct Constructors * @ingroup VIBase * Constructors to create the @link VirtualInstrument Virtual Instrument@endlink. * @{ *****************************************************************************/ /** * @brief Generic constructor. Sets default values and values that are common to all @link VI Virtual Instruments@endlink. * @param[in] aParent The parent @link VIM manager@endlink for this instrument. * * Specific @link VI Virtual Instruments@endlink (such as the Piano) have their own constructor that is more * specialized, but this will be called for each child class as well. */ public VirtualInstrument(VirtualInstrumentManager aParent) { mParent = aParent; }
protected VirtualInstrumentManager mVIM = null; // The virtual instrument manager //---------------------------------------------------------------------------- // Unity Functions //---------------------------------------------------------------------------- public void Start() { // Get the virtual instrument manager. mVIM = GameObject.Find("VirtualInstrumentManager").GetComponent <VirtualInstrumentManager>(); }