Created
July 26, 2013 04:32
-
-
Save AlexanderBrevig/6086237 to your computer and use it in GitHub Desktop.
Small script for making audio in Unity3d sound as if they are played on the other side of a phone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class Mobilephonizer : MonoBehaviour | |
{ | |
public AudioClip clip; | |
[RangeAttribute(0,20000)] | |
public int lowFrequencyCutoff = 1000; | |
[RangeAttribute(0,20000)] | |
public int highFrequencyCutoff = 5000; | |
[RangeAttribute(0,1)] | |
public float distortionLevel = 0.6f; | |
void Start() { | |
audioSource = gameObject.AddComponent<AudioSource>(); | |
highPassFilter = gameObject.AddComponent<AudioHighPassFilter>(); | |
lowPassFilter = gameObject.AddComponent<AudioLowPassFilter>(); | |
distortion = gameObject.AddComponent<AudioDistortionFilter>(); | |
highPassFilter.cutoffFrequency = lowFrequencyCutoff; | |
lowPassFilter.cutoffFrequency = highFrequencyCutoff; | |
distortion.distortionLevel = distortionLevel; | |
} | |
public void Play() | |
{ | |
audioSource.clip = clip; | |
audioSource.Play(); | |
} | |
private AudioSource audioSource; | |
private AudioHighPassFilter highPassFilter; | |
private AudioLowPassFilter lowPassFilter; | |
private AudioDistortionFilter distortion; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I couldnt get this script to funtion properly. Would you put this in an object/collider with an audio source? It seems ilke a very neat script! I am guessing this is basically obsolete with Unity5...?