All Projects → deadlyfingers → Unitywav

deadlyfingers / Unitywav

Licence: mit
WAV utility for saving and loading wav files in Unity

Labels

Projects that are alternatives of or similar to Unitywav

Unity Linesegmentsintersection
Line segments intersection for Unity.
Stars: ✭ 128 (-8.57%)
Mutual labels:  unity3d
Textureupdateexample
An example showing how to update textures from a native plugin in Unity.
Stars: ✭ 133 (-5%)
Mutual labels:  unity3d
Colorbands
Unity 3D's Gradient is a handy data type but comes with some limitations: for example you cannot set more than 8 color keys in its editor and RGB is the only color space available. ColorBand data type offers an alternative with less limitations. Creating ColorBands is fun and easy; they are stored as assets and can be accessed from code through an Evaluate method to get the color at time t, as for Gradient. RGB (or HSV) values are described by individual curves, allowing a better control over how the color function evolves between your points. Color bands are used in all kinds of applications including games, data visualization and other fields.
Stars: ✭ 137 (-2.14%)
Mutual labels:  unity3d
Cubeworld
Minecraft like game made in Unity
Stars: ✭ 130 (-7.14%)
Mutual labels:  unity3d
Unium
Automation for Unity games
Stars: ✭ 132 (-5.71%)
Mutual labels:  unity3d
Unity Webxr Export
Develop and export WebXR experiences using Unity WebGL
Stars: ✭ 130 (-7.14%)
Mutual labels:  unity3d
Gitdependencyresolverforunity
This plugin resolves git url dependencies in the package for Unity Package Manager. You can use a git url as a package dependency!
Stars: ✭ 126 (-10%)
Mutual labels:  unity3d
Tfclassify Unity
An example of using Tensorflow with Unity for image classification and object detection.
Stars: ✭ 140 (+0%)
Mutual labels:  unity3d
Meshapiexamples 2020.1
Example project for Unity 2020.1 Mesh API improvements
Stars: ✭ 133 (-5%)
Mutual labels:  unity3d
Unitylauncher
Unity Version Launcher
Stars: ✭ 137 (-2.14%)
Mutual labels:  unity3d
Nice Ts
基于puerts的Unity游戏框架,集成fairygui,protobufjs并采用addressables管理资源
Stars: ✭ 131 (-6.43%)
Mutual labels:  unity3d
Customsrp
Many mini-custom-SRPs showing how to achieve different things when creating your own SRP. Only SRP Core package is needed.
Stars: ✭ 132 (-5.71%)
Mutual labels:  unity3d
Ml Agents
Unity Machine Learning Agents Toolkit
Stars: ✭ 12,134 (+8567.14%)
Mutual labels:  unity3d
Il2cppassemblyunhollower
A tool to generate Managed->IL2CPP proxy assemblies
Stars: ✭ 126 (-10%)
Mutual labels:  unity3d
Gameframework demo
基于Unity3D框架Game Framework( http://gameframework.cn )的教程和实例,对应教程:http://www.benmutou.com/archives/category/unity3d/game-framework
Stars: ✭ 138 (-1.43%)
Mutual labels:  unity3d
Rcam
Real time volumetric video capture for live visuals
Stars: ✭ 128 (-8.57%)
Mutual labels:  unity3d
Pesocket
A C# Network Library.
Stars: ✭ 134 (-4.29%)
Mutual labels:  unity3d
Unity3d Reorderable List
List control for Unity allowing editor developers to add reorderable list controls to their GUIs.
Stars: ✭ 140 (+0%)
Mutual labels:  unity3d
Kinostreak
Anamorphic lens flare effect for Unity
Stars: ✭ 139 (-0.71%)
Mutual labels:  unity3d
Eazy Sound Manager
Eazy Sound Manager is a simple Unity3D tool which aims to make sound and music management in games easier
Stars: ✭ 135 (-3.57%)
Mutual labels:  unity3d

Wav Utility for Unity

WAV utility for recording and audio playback functions in Unity.

Usage

  • Use ToAudioClip method for loading wav file / bytes.
    • Loads .wav (PCM uncompressed) files at 8,16,24 and 32 bits and converts data to Unity's AudioClip.
    public AudioSource audioSource; // hook up with scene's AudioSource in Unity Editor inspector
    public void LoadWavFile (string filename)
      {
      	string path = string.Format ("{0}/{1}", Application.persistentDataPath, filename);
      	AudioClip audioClip = WavUtility.ToAudioClip (path);
      	audioSource.clip = audioClip;
      	audioSource.Play ();
      }
    
  • Use FromAudioClip method for saving wav file / bytes.
    • Converts an AudioClip's float data into wav byte array at 16 bit.
    private AudioClip audioClip;
    public int recordTime = 2; // no. of seconds can be set in Unity Editor inspector
    private const int sampleRate = 16000; // sample rate for recording speech
    public void RecordAudio ()
      {
      	if (Microphone.devices.Length == 0) {
      		Debug.LogWarning ("No microphone found to record audio clip sample with.");
      		return;
      	}
      	string mic = Microphone.devices [0];
      	audioClip = Microphone.Start (mic, false, recordTime, sampleRate);
      }
    
    public string SaveWavFile ()
      {
      	string filepath;
      	byte[] bytes = WavUtility.FromAudioClip (audioClip, out filepath, true);
      	return filepath;
      }
    

Notes

By design the ToAudioClip method only supports loading wav files that are stored using Unity's Application data path (Application.persistentDataPath or Application.dataPath). In order to load bundled resources it would be better to use Unity's Resources.Load("filename") typeof(AudioClip) method.

If you need to load WAV files from a remote URL then use the UnityWebRequest.GetAudioClip method which uses the AudioClip download handler.

public void LoadAudio ()
{
  string url = "<WAV_FILE_URL>";
  StartCoroutine (LoadAudioURL (url));
}
public IEnumerator LoadAudioURL (string url)
{
  UnityWebRequest www = UnityWebRequest.GetAudioClip (url, AudioType.WAV);
  yield return www.Send ();
  if (www.isError) {
    Debug.LogWarning ("Audio error:" + www.error);
  } else {
    AudioClip audioClip = ((DownloadHandlerAudioClip)www.downloadHandler).audioClip;
    audioSource.clip = audioClip;
    audioSource.Play ();
  }
}

Version history

  • 1.0 beta 1
    • Unity AudioClip to 16 bit wav file / bytes converter.
    • 8, 16, 24 or 32 bit PCM (uncompressed) wav file / bytes to Unity AudioClip converter.

Related info

Wav file formatting based on specs detailed in following articles:

Share the <3 @deadlyfingers

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].