Skip to content

Instantly share code, notes, and snippets.

View RWebster-Noble's full-sized avatar

RWebster-Noble

View GitHub Profile
@RWebster-Noble
RWebster-Noble / SavWav.cs
Created February 25, 2021 16:41 — forked from darktable/SavWav.cs
Unity3D: script to save an AudioClip as a .wav file.
// Copyright (c) 2012 Calvin Rien
// http://the.darktable.com
//
// This software is provided 'as-is', without any express or implied warranty. In
// no event will the authors be held liable for any damages arising from the use
// of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//javascript:%28function%28%29%7Bfunction makeDate%28hours%2Cmins%29%7Bvar date%3Dnew Date%280%29%3Bdate.setHours%28hours%29%3Bdate.setMinutes%28mins%29%3Breturn date%7Dfunction calculateFlexitime%28times%2Cnow%2CcurrentBalanceMins%29%7Bfunction toTimeString%28mins%29%7Bfunction pad%28d%29%7Breturn d<10%3F"0"%2Bd.toString%28%29%3Ad.toString%28%29%7Dvar hoursString%3DMath.floor%28Math.abs%28mins%2F60%29%29%3Bvar minsString%3Dpad%28Math.floor%28Math.abs%28mins%29%2560%29%29%3Breturn hoursString%2B"%3A"%2BminsString%7Dvar minsWorked%3D0%3Bfor%28var i%3D0%3Bi%2B1<times.length%3Bi%2B%3D2%29%7Bvar timeIn%3Dtimes%5Bi%5D%3Bvar timeOut%3Dtimes%5Bi%2B1%5D%3BminsWorked%2B%3D%28timeOut.getTime%28%29-timeIn.getTime%28%29%29%2F%2860%2A1e3%29%7Dvar minsOnBreak%3D0%3Bfor%28var i%3D1%3Bi%2B1<times.length%3Bi%2B%3D2%29%7Bvar timeOut%3Dtimes%5Bi%5D%3Bvar timeIn%3Dtimes%5Bi%2B1%5D%3BminsOnBreak%2B%3D%28timeIn.getTime%28%29-timeOut.getTime%28%29%29%2F%2860%2A1e3%29%7Dif%28minsOnBreak<30%26%26minsWorked>30%29%7Bvar wastedBreak%3D3