Vizard 7 » Reference » Multimedia » Recording sound with vizmic
7.6

Recording sound with vizmic

The vizmic module allows you to record sound from a microphone while running a Vizard world. It also allows you to monitor the audio level of the incoming sound in real-time and use the data for such purposes as animating lip-flapping.

Recording sound

Vizmic will record sound from a system microphone to a .wav file.

import vizmic
vizmic.startRecording('voice.wav')

Monitoring sound level

The vizmic module also allows you to monitor the sound level as it comes in. This functionality can be particularly handy if you're using sound to animate the flapping lips of an avatar:

vizmic.startMonitoring()

#add an avatar in an idling state
avatar = viz.add('vcc_female.cfg', pos = [0,0.3,1], euler = [180,0,0])
avatar.state(1)

#adjust the amount to morph the avatar lips
#based on the monitor level
def UpdateLips():
    flap = vizmic.getMonitorLevel() #Get the monitor level.
    print(flap)
    avatar.setMorph(2,flap*25) #Morph mouth to a multiple of the monitor level.
vizact.ontimer(0,UpdateLips)

Vizmic commands

The following commands are available in the vizmic module:

Function

Description

vizmic.getMonitorLevel()

Return current monitor level between 0 and 1

vizmic.isMonitoring()

Return whether monitoring is currently active

vizmic.isRecording()

Return whether recording is currently active

vizmic.startMonitoring()

Start monitoring the microphone for audio levels

vizmic.startRecording( <filename>, sampleRate=44100,bitsPerSample=16,channels=1)

Start recording microphone to <filename> at specified quality

vizmic.stopMonitoring()

Stop monitoring the microphone for audio levels

vizmic.stopRecording()

Stop recording from microphone

See also

In this section:

Multimedia basics

Video Basics

Sound basics

Advanced 3D sound

Ambisonic 3D sound

Multimedia command table

Other sections:

Tutorial: Multimedia

Tutorial: 3D sound

Example scripts:

Adding sounds

3D sound