Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by panoramabeats · Aug 12, 2017 at 03:14 AM · uiaudioslidermixingsetfloat

How to set a button to change slider to specific value

I have a slider that controls an echo/delay time as wired to the audio mixer's effects (via exposed parameters - the parameter is called "delayTime." This is a musical app and so there is a tempo (BPM) and I have created buttons that automatically set to Tempo-Based Delays of 1/4 note, 1/8 note, and so forth.

What I need is for this button to also change the slider to be at that value. For instance, if by pressing the 1/4 Note delay button, the delay time changes to 600 ms, the Delay Time Slider should adjust accordingly. In my current setup, it does not.

In order to access the Audio Mixer ("masterMixer") I've tried using something called the masterMixer.GetFloat function, but not sure how to use it. Does anyone with Unity audio experience or relevant UI knowledge know how I could change this script?

Thank you!!

using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.Audio;

public class MixLevels: MonoBehaviour {

 public AudioMixer masterMixer;

 public radarScript _radarScript;

 public Slider DelayTimeSlider;



 //   Tempo-Based Delay Values:

 public float QuarterNoteDelayTime;
 public float DottedEighthNoteDelayTime;
 public float EighthNoteDelayTime;
 public float DottedQuarterNoteDelayTime;
 public float DelayTime;



 void Update()
 {
     
 
     QuarterNoteDelayTime = (60000 / _radarScript.BPM);
 
     DottedEighthNoteDelayTime = (45000 / _radarScript.BPM);
 
     EighthNoteDelayTime = (30000 / _radarScript.BPM);

     DottedQuarterNoteDelayTime = (90000 / _radarScript.BPM);
 
 }

     //   TEMPO DELAY EQUATION:
     //      Quarter Note Delay Time = (60000 / BPM);
     //   where 60,000 = milliseconds per minute
     

 //  FOR  TEMPO-BASED DELAY BUTTONS

 public void SetQuarterNoteDelayTime ()
 {
     
     masterMixer.SetFloat ("delayTime", QuarterNoteDelayTime);
     print ("button pressed; QuarterNoteDelayTime = " + QuarterNoteDelayTime);

 }

 public void SetDottedEighthNoteDelayTime ()
 {
     
     masterMixer.SetFloat ("delayTime", DottedEighthNoteDelayTime); 
     print ("button pressed; DottedEighthNoteDelayTime = " + DottedEighthNoteDelayTime);
 }

 public void SetEighthNoteDelayTime ()
 {
     
     masterMixer.SetFloat ("delayTime", EighthNoteDelayTime); 
     print ("button pressed; EighthNoteDelayTime= " + EighthNoteDelayTime);
 }

 public void SetDottedQuarterNoteDelayTime ()
 {
     
     masterMixer.SetFloat ("delayTime", DottedQuarterNoteDelayTime); 
     print ("button pressed; DottedQuarterNoteDelayTime = " + DottedQuarterNoteDelayTime);
 }
     

 //  FOR  MIXER FX PANEL WIRING


 public void SetPitchLvl (float pitchLvl)
 {
     masterMixer.SetFloat ("pitchMaster", pitchLvl); 
 }
     
 public void SetReverbDecayLvl (float reverbDecayLvl)
 {
     masterMixer.SetFloat ("reverbDecaytime", reverbDecayLvl); 
 }

 public void SetReverbLvl (float reverbLvl)
 {
     masterMixer.SetFloat ("reverbMaster", reverbLvl); 
 }

 public void SetFreqCutLvl (float freqCutLvl)
 {
     masterMixer.SetFloat ("filterCutoff", freqCutLvl); 
 }

 public void SetMasterVolumeLvl (float masterVolumeLvl)
 {
     masterMixer.SetFloat ("MasterVolume", masterVolumeLvl); 
 }

 public void SetChorusLvl (float chorusLvl)
 {
     masterMixer.SetFloat ("chorusDepth", chorusLvl); 
 }

 public void SetDistortionLvl (float distortionLvl)
 {
     masterMixer.SetFloat ("distortionLevel", distortionLvl); 
 }

 public void SetReverbDensityLvl (float reverbDensityLvl)
 {
     masterMixer.SetFloat ("reverbDensity", reverbDensityLvl); 
 }

 public void SetDelaySendLvl (float delaySendLvl)
 {
     masterMixer.SetFloat ("delaySend", delaySendLvl); 
 }

 public void SetDelayTimeLvl (float delayTime)
 {
     masterMixer.SetFloat ("delayTime", delayTime); 

 }

 public void SetDelayFeedbackLvl (float delayFeedback)
 {
     masterMixer.SetFloat ("delayFdbk", delayFeedback); 
 }


}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

162 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How Do I Make A Change A Volume With A Slider? 3 Answers

Adjusting Audio Volume via UI Slider 0 Answers

UI not working properly in webgl build (new input system) 0 Answers

Drag UI Slider in VR with Vive Controllers 1 Answer

Slider OnValueChanged not letting me chose a function to send it to 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges