Skip to content

Instantly share code, notes, and snippets.

@AlexanderBrevig
Created July 26, 2013 04:32
Show Gist options
  • Save AlexanderBrevig/6086237 to your computer and use it in GitHub Desktop.
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
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;
}
@stuleelight
Copy link

stuleelight commented May 21, 2016

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...?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment