# Unit generator

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Unit_generator
> Markdown URL: https://mediated.wiki/source/Unit_generator.md
> Source: https://en.wikipedia.org/wiki/Unit_generator
> Source revision: 1276621793
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description|Basic formal unit in MUSIC-N-style programming languages}}
'''Unit generators''' (or ''ugens'') are the basic formal units in many [MUSIC-N](/source/MUSIC-N)-style [computer music programming languages](/source/computer_music_programming_languages).<ref>{{Cite web |title=ChucK - [Language Specification] |url=https://chuck.stanford.edu/doc/language/ugen.html |access-date=2024-11-03 |website=chuck.stanford.edu}}</ref> They are sometimes called [opcode](/source/opcode)s (particularly in [Csound](/source/CSound)),<ref>{{Cite journal |last=Lazzarini |first=Victor |date=2017 |title=Supporting an Object-Oriented Approach to Unit Generator Development: The Csound Plugin Opcode Framework |url=https://mural.maynoothuniversity.ie/11607/ |journal=Applied Sciences |language=en |volume=7 |issue=10 |pages=970 |issn=2076-3417 |doi=10.3390/app7100970|doi-access=free }}</ref> though this expression is not considered accurate in that these are not written directly as [machine-level instructions](/source/Machine_code).{{cn|date=November 2024|reason=It would be good to have verification here because this reads more like original research or synth, but I'm not familiar enough with the tech to definitively say.}} 

Unit generators form the building blocks for designing [synthesis](/source/Sound_synthesis) and [signal processing](/source/signal_processing) [algorithm](/source/algorithm)s in software.<ref name=supercollider-ugen>{{Cite web |title=UGen {{!}} SuperCollider 3.13.0 Help |url=https://docs.supercollider.online/Classes/UGen.html |access-date=2024-11-03 |website=docs.supercollider.online}}</ref>
The unit generator theory of sound synthesis was first developed and implemented by [Max Mathews](/source/Max_Mathews)<ref>{{Cite journal |last=Smith |first=Julius |date=2007 |title=Unit-generator architectures in computer music |url=https://www.researchgate.net/publication/252185943 |journal=[Journal of the Acoustical Society of America](/source/Journal_of_the_Acoustical_Society_of_America) |volume=122 |issue=5 |page=3080 |doi=10.1121/1.2943000}}</ref> and his colleagues at [Bell Labs](/source/Bell_Labs) in the 1950s.<ref>{{Cite web |date=2000-04-07 |title=Bell Labs: Background: Bell Labs Text-to-Speech Synthesis: Then and Now |url=http://www.bell-labs.com/news/1997/march/5/2.html |archive-url=https://web.archive.org/web/20000407081031/http://www.bell-labs.com/news/1997/march/5/2.html |archive-date=2000-04-07 |access-date=2024-11-03 |website=bell-labs.com |url-status=dead}}</ref>

== Examples ==
A simple unit generator called OSC could generate a sinusoidal waveform of a specific frequency (given as an input or argument to the [function](/source/function_(programming)) or [class](/source/class_(computer_science)) that represents the unit generator). ENV could be a unit generator that delineates a breakpoint function. Thus ENV could be used to drive the [amplitude](/source/amplitude) [envelope](/source/ADSR_envelope) of the oscillator OSC through the equation OSC*ENV. Unit generators often use predefined arrays of values for their functions (which are filled with [waveform](/source/waveform)s or other [shape](/source/shape)s by calling a specific generator function).

In the [SuperCollider](/source/SuperCollider) language, the .ar [method](/source/method_(computer_science)) in the SinOsc class<ref>{{Cite web |title=SinOsc {{!}} SuperCollider 3.13.0 Help |url=https://docs.supercollider.online/Classes/SinOsc.html |access-date=2024-11-03 |website=docs.supercollider.online}}</ref> [inherits](/source/Inheritance_(object-oriented_programming)) methods from an overarching unit generator class (UGen)<ref name=supercollider-ugen /> that generates a [sine wave](/source/sine_wave).  The example below makes a sine wave at frequency 440, phase 0, and amplitude 0.5.
:<pre><nowiki>SinOsc.ar(440, 0, 0.5);</nowiki></pre>

==See also==
*[Tuning generator](/source/Tuning_generator)

==References==
{{reflist}}

Category:Acoustics software
Category:Audio programming languages

{{music-software-stub}}

---
Adapted from the Wikipedia article [Unit generator](https://en.wikipedia.org/wiki/Unit_generator) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Unit_generator?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
