### Start Chuck Server Source: https://github.com/calysto/chuck/blob/master/README.md Example command to start the ChucK server. This command specifies ALSA audio driver, verbose logging, and the OSC port. ```bash chuck.alsa --verbose:9 --port:9000 chuck/osc/oscrecv.ck ``` -------------------------------- ### Install Chuck Python Library Source: https://github.com/calysto/chuck/blob/master/README.md Use this command to install the Chuck Python library. Ensure you have pip installed. ```python pip install chuck -U ``` -------------------------------- ### Connect and Pluck a Mandolin (Example) Source: https://github.com/calysto/chuck/blob/master/docs/API.md A complete example showing how to connect a Mandolin and then pluck it with maximum strength. ```python m = Mandolin() m.connect() m.pluck(1) ``` -------------------------------- ### Orchestrate Rhythmic Sounds with doTogether Source: https://github.com/calysto/chuck/blob/master/docs/API.md Demonstrates creating a musical piece with three different instruments playing simultaneously but starting at different times. Requires the Shakers, StruckBar, and Mandolin instruments to be available. ```python # helper function to play one sound / note def playOnce(instrument, time, strength): instrument.noteOn(strength) wait(time) def playShakers(): shakers = Shakers() shakers.connect() beat = 0.4 for i in range(7): playOnce(shakers, beat, 1) playOnce(shakers, beat/2, .8) playOnce(shakers, beat/2, .8) playOnce(shakers, beat, 1) shakers.noteOn(1) def playBar(): bar = StruckBar() bar.connect() beat = 0.4 wait(beat * 6) # wait for 2 measures / loop iterations for i in range(5): playOnce(bar, beat/2, .8) playOnce(bar, beat/2, .8) playOnce(bar, beat, 1) playOnce(bar, beat, 1) bar.noteOn(1) def playMandolin(): m = Mandolin() m.connect() m.setGain(0.3) beat = 0.4 wait(beat * 12) # wait for 4 measures / loop iterations for i in range(3): playOnce(m, beat, 1) playOnce(m, beat, 1) playOnce(m, beat/2, .8) playOnce(m, beat/2, .8) m.noteOn(1) doTogether(playShakers, playBar, playMandolin) ``` -------------------------------- ### Control Saxophone Sound with noteOn and noteOff Source: https://github.com/calysto/chuck/blob/master/docs/API.md Starts and stops the sound of a saxophone using noteOn and noteOff functions with specified velocities. Allows for controlled sound playback. ```python x = Saxophone() x.connect() x.noteOn(0.8) wait(1.0) x.noteOff(0.2) ``` -------------------------------- ### Create and Connect a Mandolin Source: https://github.com/calysto/chuck/blob/master/docs/API.md Creates a virtual mandolin instance and connects it to the sound output. This is a prerequisite before performing actions like plucking. ```python m = Mandolin() m.connect() ``` -------------------------------- ### Combine Instrument Playback Functions Source: https://github.com/calysto/chuck/blob/master/docs/API.md Demonstrates how to play multiple instrument functions concurrently using the `doTogether` function. ```python doTogether(playSaxophone, playMandolin) ``` -------------------------------- ### Initialize Chuck Framework Source: https://github.com/calysto/chuck/blob/master/docs/API.md Initialize the communication and synthesis framework. This must be called before using other Chuck functions. ```python init() ``` -------------------------------- ### Import Chuck Modules Source: https://github.com/calysto/chuck/blob/master/docs/API.md Import all necessary modules from the chuck library to begin. Ensure a Chuck server is running before execution. ```python from chuck import * ``` -------------------------------- ### Create and Connect SineWave Generator Source: https://github.com/calysto/chuck/blob/master/docs/API.md Create a SineWave generator and connect it to the system's audio output. A prompt may appear on Windows for permission. ```python s = SineWave() s.connect() ``` -------------------------------- ### Connect a SineWave Instrument Source: https://github.com/calysto/chuck/blob/master/docs/API.md Initializes and connects a SineWave instrument to the audio output. This is a fundamental step before generating sound with a SineWave. ```python sw = SineWave() sw.connect() ``` -------------------------------- ### Connect and Disconnect an Instrument Source: https://github.com/calysto/chuck/blob/master/docs/API.md Demonstrates the basic connection and disconnection process for an instrument, which is common to all instrument types. ```python man = Mandolin() man.connect() man.disconnect() ``` -------------------------------- ### Sitar Source: https://github.com/calysto/chuck/blob/master/docs/API.md Methods for controlling the Sitar synthesis model. ```APIDOC ## Sitar A sitar ### Methods * `pluck(strength)`: pluck the string (0.0 <= strength <= 1.0) ``` -------------------------------- ### BlowBottle Source: https://github.com/calysto/chuck/blob/master/docs/API.md Methods for controlling the BlowBottle (BlowBotl) synthesis model. ```APIDOC ## BlowBottle A blown bottle (**BlowBotl** in ChucK) ### Methods * `setVibrato(vibratoFreq, vibratoGain, noiseGain)`: set vibrato frequency and gain, and noise component gain (vibratoFreq in Hertz, 0.0 <= vibratoGain <= 1.0, 0.0 <= noiseGain <= 1.0) * `setVolume(volume)`: set volume (0.0 <= volume <= 1.0) * `setAttackRate(seconds)`: set rate of attack in seconds (seconds >= 0.0) * `startBlowing(strength)`: start blowing (0.0 <= strength <= 1.0) * `stopBlowing(floatValue)`: stop blowing (0.0 <= floatValue <= 1.0) ``` -------------------------------- ### PluckedString Source: https://github.com/calysto/chuck/blob/master/docs/API.md Methods for controlling the PluckedString (StifKarp) synthesis model. ```APIDOC ## PluckedString A Karplus-Strong plucked string model (**StifKarp** in ChucK) ### Methods * `setPickupPosition(position)`: set pickup position (0.0 <= position <= 1.0) * `setSustain(sustain)`: set the string's sustain (0.0 <= sustain <= 1.0) * `setStretch(stretch)`: set the string's stretch (0.0 <= stretch <= 1.0) * `pluck(strength)`: pluck the string (0.0 <= strength <= 1.0) * `setBaseLoopGain(gain)`: set "base loop gain" (0.0 <= gain <= 1.0) ``` -------------------------------- ### Configure FMVoices Instrument Source: https://github.com/calysto/chuck/blob/master/docs/API.md Connects an FMVoices instrument and sets its vowel parameter. This allows for basic voice synthesis configuration. ```python fmv = FMVoices() fmv.connect() fmv.setVowel(0.5) ``` -------------------------------- ### Bowed Instrument Controls Source: https://github.com/calysto/chuck/blob/master/docs/API.md Control parameters for the Bowed instrument, including bow pressure and position, vibrato frequency and gain, and volume. ```python setBow(**pressure**, **position**) ``` ```python setVibrato(**freq**, **gain**) ``` ```python setVolume(**volume**) ``` ```python startBowing(**floatValue**) ``` ```python stopBowing(**floatValue**) ``` -------------------------------- ### Map Robot Sensors to Sound with MoogSynthesizer Source: https://github.com/calysto/chuck/blob/master/docs/API.md Uses fluke obstacle sensors to control sound frequency and filter sweep rate. Ensure the robot is connected and obstacle sensors are functional before running. ```python # normalize obstacle sensor values to be between 0.0 and 1.0 def normalizeObstacle(v): # assume the highest sensor value is around 1100. maxObstacle = 1100.0 if v > maxObstacle: v = maxObstacle # normalize so that the result is between 0 and 1, # with nearer obstacles returning values closer to 0 return 1.0 - v / maxObstacle # set up an instrument m = MoogSynthesizer() m.connect() m.noteOn(1.0) # in a loop, get new obstacle values and update the sound while timeRemaining(30): # get obstacle values L, C, R = getObstacle() # connect right value to frequency (and get a freq between 0.0 and 500.0) freq = normalizeObstacle(R) * 500 m.setFrequency(freq) # connect left value to another parameter (between 0.0 and 1.0) rate = normalizeObstacle(L) m.setFilterSweepRate(rate) # turn off instrument when done m.noteOff(1.0) ``` -------------------------------- ### Define Mandolin Playback Function Source: https://github.com/calysto/chuck/blob/master/docs/API.md Defines a Python function to initialize, connect, and play a Mandolin instrument. ```python def playMandolin(): mandolin = Mandolin() mandolin.connect() mandolin.pluck(1) wait(1) ``` -------------------------------- ### Common Instrument Operations Source: https://github.com/calysto/chuck/blob/master/docs/API.md These operations are available for all instruments in the Calysto Chuck library. ```APIDOC ## Operations for all instruments All of the following functions can be called by preceding them with the name of the instrument and a dot. For example: ```python man = Mandolin() man.connect() man.disconnect() ``` * `connect()`: connect to sound output device * `disconnect()`: disconnect from sound output device * `noteOn(velocity)`: start playing a note / making sound (0.0 <= **velocity** <= 1.0) * `noteOff(velocity)`: stop playing a note / making sound (0.0 <= **velocity** <= 1.0) * `setGain(gain)`: set gain to the given value (**gain** >= 0.0) * `setFrequency(freq)`: set frequency to the given value (**freq** is in Hertz) ``` -------------------------------- ### Define Saxophone Playback Function Source: https://github.com/calysto/chuck/blob/master/docs/API.md Defines a Python function to initialize, connect, and play a Saxophone instrument for a specified duration. ```python from myro import * from myro.chuck import * initChuck() def playSaxophone(): sax = Saxophone() sax.connect() sax.startBlowing(1) wait(1) sax.stopBlowing(1) ``` -------------------------------- ### Saxophone Source: https://github.com/calysto/chuck/blob/master/docs/API.md Methods for controlling the Saxophone synthesis model. ```APIDOC ## Saxophone A saxophone or similar wind instrument (**Saxofony** in ChucK) ### Methods * `setStiffness(stiffness)`: set reed stiffness (0.0 <= stiffness <= 1.0) * `setAperture(aperture)`: set reed aperture (0.0 <= aperture <= 1.0) * `setPressure(pressure)`: set pressure / volume (0.0 <= pressure <= 1.0) * `setVibrato(vibratoFreq, vibratoGain, noiseGain)`: set frequency and gain of vibrato, and gain of noise component (vibratoFreq in Hertz, 0.0 <= vibratoGain <= 1.0, 0.0 <= noiseGain <= 1.0) * `setBlowPosition(position)`: set blow position / lip stiffness (0.0 <= position <= 1.0) * `startBlowing(strength)`: start blowing (0.0 <= strength <= 1.0) * `stopBlowing(strength)`: stop blowing (0.0 <= strength <= 1.0) * `setAttackRate(seconds)`: set rate of attack (sound's beginning) in seconds ``` -------------------------------- ### StruckBar Source: https://github.com/calysto/chuck/blob/master/docs/API.md Methods for controlling the StruckBar (ModalBar) synthesis model. ```APIDOC ## StruckBar Struck bar instruments (**ModalBar** in ChucK) ### Methods * `setStickHardness(hardness)`: set stick hardness (0.0 <= hardness <= 1.0) * `setStrikePosition(position)`: set strike position (0.0 <= position <= 1.0) * `setVibrato(freq, gain)`: set frequency and gain of vibrato (freq in Hertz, 0.0 <= gain <= 1.0) * `setDirectGain(gain)`: set direct gain (0.0 <= gain <= 1.0) * `setMasterGain(gain)`: set master gain (0.0 <= gain <= 1.0) * `setVolume(volume)`: set volume (0.0 <= volume <= 1.0) * `strike(strength)`: strike the bar (0.0 <= strength <= 1.0) * `damp(amount)`: damp the bar (0.0 <= amount <= 1.0) * `setMode(mode, ratio, radius, gain)`: set mode info (mode is 0 or 1, ratio >= 0.0, 0.0 <= radius <= 1.0, 0.0 <= gain <= 1.0) * `preset(instrumentNumber)`: change the settings to a preset instrument by number (0 <= instrumentNumber <= 8). Below is a list of preset instruments and what number to use for each: * Marimba = 0 * Vibraphone = 1 * Agogo = 2 * Wood1 = 3 * Reso = 4 * Wood2 = 5 * Beats = 6 * Two Fixed = 7 * Clump = 8 ``` -------------------------------- ### MoogSynthesizer Source: https://github.com/calysto/chuck/blob/master/docs/API.md Methods for controlling the MoogSynthesizer synthesis model. ```APIDOC ## MoogSynthesizer A Moog synthesizer (**Moog** in ChucK) ### Methods * `setFilterQ(floatValue)`: set filter's Q value (0.0 <= floatValue <= 1.0) * `setFilterSweepRate(rate)`: set filter sweep rate (0.0 <= rate <= 1.0) * `setVibrato(freq, gain)`: set frequency and gain of vibrato (freq in Hertz, 0.0 <= gain <= 1.0) * `setAfterTouch(afterTouch)`: set aftertouch (0.0 <= afterTouch <= 1.0) ``` -------------------------------- ### Modify SineWave Gain Source: https://github.com/calysto/chuck/blob/master/docs/API.md Adjust the gain (loudness) of the SineWave generator. Setting gain to 0.0 mutes the sound without disconnecting. ```python s.connect() # connect it again first, to hear it s.setGain(1.0) wait(0.5) s.setGain(0.0) wait(0.5) s.setGain(0.5) ``` -------------------------------- ### BlowHole Instrument Controls Source: https://github.com/calysto/chuck/blob/master/docs/API.md Control parameters for the BlowHole instrument, such as reed stiffness, noise gain, tonehole size, vent frequency, pressure, blowing strength, and attack rate. ```python setReedStiffness(**stiffness**) ``` ```python setNoiseGain(**gain**) ``` ```python setToneHoleSize(**size**) ``` ```python setVent(**vent**) ``` ```python setPressure(**pressure**) ``` ```python startBlowing(**strength**) ``` ```python stopBlowing(**floatValue**) ``` ```python setAttackRate(**seconds**) ``` -------------------------------- ### SineWave Instrument Source: https://github.com/calysto/chuck/blob/master/docs/API.md Specific operations for the SineWave instrument. ```APIDOC #### SineWave A sinusoidal oscillator or sine-wave generator (**SinOsc** in ChucK) * No additional operations Example: ```python sw = SineWave() sw.connect() ``` ``` -------------------------------- ### Pluck a Mandolin Source: https://github.com/calysto/chuck/blob/master/docs/API.md Plucks the mandolin string with a specified strength. The strength parameter ranges from 0.0 (light pluck) to 1.0 (hard pluck). ```python m.pluck(0.2) wait(1) m.pluck(1.0) ``` -------------------------------- ### Shakers Source: https://github.com/calysto/chuck/blob/master/docs/API.md Methods for controlling the Shakers synthesis model. ```APIDOC ## Shakers Collisions of multiple independent sound-producing objects ### Methods * `setEnergy(shakeEnergy)`: set shake energy (0.0 <= shakeEnergy <= 1.0) * `setDecay(decay)`: set system decay (0.0 <= decay <= 1.0) * `setObjects(numObjects)`: set number of objects (0 <= numObjects <= 128) * `preset(number)`: change the settings to a preset instrument by number (0 <= number <= 22). Below is a list of preset instruments and what number to use for each: * Maraca = 0 * Cabasa = 1 * Sekere = 2 * Guiro = 3 * Water Drops = 4 * Bamboo Chimes = 5 * Tambourine = 6 * Sleigh Bells = 7 * Sticks = 8 * Crunch = 9 * Wrench = 10 * Sand Paper = 11 * Soda Can = 12 * Next Mug = 13 * Penny + Mug = 14 * Nickle + Mug = 15 * Dime + Mug = 16 * Quarter + Mug = 17 * Franc + Mug = 18 * Peso + Mug = 19 * Big Rocks = 20 * Little Rocks = 21 * Tuned Bamboo Chimes = 22 ``` -------------------------------- ### Mandolin Instrument Source: https://github.com/calysto/chuck/blob/master/docs/API.md Specific operations for the Mandolin instrument. ```APIDOC #### Mandolin A mandolin * `pluck(strength)`: pluck the mandolin (0.0 <= **strength** <= 1.0) Example: ```python m = Mandolin() m.connect() m.pluck(1) ``` ``` -------------------------------- ### Voice Instrument Source: https://github.com/calysto/chuck/blob/master/docs/API.md Specific operations for the Voice instrument. ```APIDOC #### Voice Another voice synthesizer (**VoicForm** in ChucK) * `setPhoneme(phoneme)`: set the phoneme to the given string value (**phoneme** in ["eee", "ihh", "ehh", "aaa", "ahh", "aww", "ohh", "uhh", "uuu", "ooo", "rrr", "lll", "mmm", "nnn", "nng", "ngg", "fff", "sss", "thh", "shh", "xxx", "hee", "hoo", "hah", "bbb", "ddd", "jjj", "ggg"]) * `setPhonemeNumber(number)`: set the phoneme given a number value (0 <= **number <= 128) * `sing(floatValue)`: re-start singing (0.0 <= **floatValue** <= 1.0) * `quiet(floatValue)`: stop singing (0.0 <= **floatValue** <= 1.0) * `setVoiced(mix)`: set mix for voiced component of the sound (0.0 <= **mix** <= 1.0) * `setUnvoiced(mix)`: set mix for unvoiced component of the sound (0.0 <= **mix** <= 1.0) * `setVoiceMix(mix)`: set voiced/unvoiced mix together (0.0 <= **mix** <= 1.0) * `setPitchSweepRate(rate)`: set pitch sweep (0.0 <= **rate** <= 1.0) * `setVibrato(freq, gain)`: set frequency and gain of vibrato (**frequency** in Hertz, 0.0 <= **gain** <= 1.0) * `setLoudness(loudness)`: set the perceived loudness (0.0 <= **loudness** <= 1.0) ``` -------------------------------- ### Disconnect SineWave Generator Source: https://github.com/calysto/chuck/blob/master/docs/API.md Disconnect the SineWave generator from the audio output to stop the sound. This mutes the output without stopping the generator. ```python s.disconnect() ``` -------------------------------- ### FMVoices Instrument Source: https://github.com/calysto/chuck/blob/master/docs/API.md Specific operations for the FMVoices instrument. ```APIDOC #### FMVoices A voice synthesizer * `setVowel(vowel)`: set the vowel given a numerical value (0.0 <= **vowel** <= 1.0) * `setSpectralTilt(spectralTilt)`: set spectral tilt (related to loudness) (0.0 <= **spectralTilt** <= 1.0) * `setAdsrTarget(target)`: set ADSR targets (related to how the sound changes over time) (0.0 <= **target** <= 1.0) Example: ```python fmv = FMVoices() fmv.connect() fmv.setVowel(0.5) ``` ``` -------------------------------- ### SineWave Frequency Modulation Loop Source: https://github.com/calysto/chuck/blob/master/docs/API.md A while loop that continuously modifies the SineWave's frequency, causing it to increase over time. The loop runs as long as 30 seconds remain. ```python freq = 100.0 while timeRemaining(30): s.setFrequency(freq) wait(0.2) freq = freq * 1.01 ``` -------------------------------- ### Modify SineWave Frequency Source: https://github.com/calysto/chuck/blob/master/docs/API.md Change the frequency of the SineWave generator in Hertz while it is playing. This alters the pitch of the sound. ```python s.setFrequency(200) wait(1.0) s.setFrequency(400) wait(1.0) s.setFrequency(444.5) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.