LATEST VERSION 2.2 (16.07.2017)

Description

playernextUPlayerNext is an URBI module enabling sound reproduction and recording. Its purpose is to provide programmers with powerful and efficient sample and stream (MP3, MP2, MP1, OGG, WAV, AIFF, and more) options. It enables the robot to play back various sounds, sentences recorded by external text-to-speech software, play music or broadcast radio streams. It also enables recording audio from multiple input devices (microphones, Kinect,...).

The module was enriched with a set of real-time DSP functions/effects including reverse playback, seeking, tempo & pitch control, equalizer, phaser, autowah, echo, distortion, chorus, dynamic aplification, BPM counter and beat trigger.

All functions are based on BASS audio library. BASS is free for non-commercial use. If you are a non-commercial entity (eg. an individual) and you are not making any money from your product (through sales, advertising, etc), then you can use BASS in it for free. More info about BASS can be found here: http://www.un4seen.com

Links to the RMF FM list of streams can be found here (use m3u or pls links): http://files.kusmierz.be/rmf

Requirements

UPlayerNext was compiled with all the shared libraries. Copy them to the uobjects folder or set path in system environment variable (PATH).
  • bass.dll
  • bass_fx.dll

Module functions

Sound playback slots

UPlayerNext.Play("path or URL") - play back file or stream,
UPlayerNext.Load("path or URL") - load file or stream without playing, use Start function to play back loaded file or stream,
UPlayerNext.Stop() - stop playing sound,
UPlayerNext.ClearAll() - stop and clear all playback sounds (even in all other module instances).
UPlayerNext.Pause() - pause playback of a file or stream,
UPlayerNext.Start() - start (or resume) playback of a file or stream.
 
UPlayerNext.tempoEnable - use tempo mode, ATTENTION: must be set to true before you load a file,
UPlayerNext.reverseEnable - use reverse mode, ATTENTION: must be set to true before you load a file,
UPlayerNext.isPlaying - true if playback is on,
UPlayerNext.position - get or set current playback position,
UPlayerNext.lenght - get current playback lenght,
UPlayerNext.masterVolume; - get or set master volume,
UPlayerNext.volume - get or set playback volume,
UPlayerNext.vumeter - get VU meter value (play or record),
UPlayerNext.cpu - get the current CPU usage of all UPlayerNext modules.

Recording slots

UPlayerNext.StartRecord(input_device,"path/filename.wav") - start recording from given input device (-1 - use default input)
UPlayerNext.StartListening(input_device) - start listening from given input device (-1 - use default input) to observe input loudness (vumeter slot)
UPlayerNext.StopRecord() - stop record,
UPlayerNext.SetRecordLevel(input, level) - set the record level of a chosen input (level as a percentage),
UPlayerNext.GetRecordLevel(input) - get the record level of a chosen input (level as a percentage),
UPlayerNext.inputDevices - list the names of all input devices.

URL slots

ATTENTION: Use these slots when you are playing back a broadcast stream.
UPlayerNext.urlInfo - broadcast information about a stream,
UPlayerNext.urlName - broadcast station name,
UPlayerNext.urlBitrate - bitrate information about stream,
UPlayerNext.urlGenre - genre information about stream,
UPlayerNext.urlTag - information about the currently playing song (updatated every new song).

TAG ID3 slots

ATTENTION: Availability depends on the file.
UPlayerNext.title - song title,
UPlayerNext.artist - artist name,
UPlayerNext.album - album name,
UPlayerNext.year  - year,
UPlayerNext.comment - comment.

Tempo and reverse slots

ATTENTION: tempoEnable or reverseEnable must be set to true before playing back sound.
UPlayerNext.SetAntiAliasFilter(bool) - use an anti-aliasing filter in tempo mode,
UPlayerNext.SetReverse(bool) - play back sound in reverse mode (true - playback in reverse),
 
UPlayerNext.tempoTempo - tempo value [-95%..0..+5000%] percent,
UPlayerNext.tempoPitch - pitch (key) [-60....0....+60] semitones,
UPlayerNext.tempoRate - samplerate in Hz (Internally calculated from the percentage set as tempo).

FX slots

ATTENTION: once set, the effect will be added to all new playback. To remove use Remove...() functions.
UPlayerNext.SetEqualizer(Bass, Mid, Treble) - set gain in dB [-15dB...0...+15dB], three frequencies - 125Hz, 1kHz, 8kHz (functionality can be expanded in the sources),
UPlayerNext.RemoveEqualizer() - remove equalizer,
 
UPlayerNext.SetPhaser(WetMix, DryMix, Feedback, Rate, Range, Freq) - add phaser effect,
UPlayerNext.RemovePhaser() - remove phaser,
DryMix -  Dry (unaffected) signal mix [-2....+2]
WetMix -  Wet (affected) signal mix [-2....+2]
Feedback -  Output signal to feed back into input [-1....+1]
Rate -  Rate of sweep in cycles per second [0<...<10]
Range -  Sweep range in octaves [0<...<10]
Freq -  Base frequency of sweep range [0<..1000]
UPlayerNext.SetAutoWah(WetMix, DryMix, Feedback, Rate, Range, Freq) - add auto wah effect,
UPlayerNext.RemoveAutoWah() - remove auto wah,
DryMix  -  Dry (unaffected) signal mix [-2....+2]
WetMix -  Wet (affected) signal mix [-2....+2]
Feedback -  Output signal to feed back into input [-1....+1]
Rate -  Rate of sweep in cycles per second [0<...<10]
Range -  Sweep range in octaves [0<...<10]
Freq -  Base frequency of sweep range [0<..1000]
UPlayerNext.SetDamp(Target, Quiet, Rate, Gain, Delay) - add dynamic amplification effect,
UPlayerNext.RemoveDamp()
Target -  Target volume level [0<....1] linear
Quiet -  Quiet volume level [0.....1] linear
Rate -  Amplification adjustment rate [0.....1] linear
Gain -  Amplification level [0..1..n] linear
Delay -  Delay in seconds before increasing level [0.....n] linear
UPlayerNext.SetChorus(DryMix, WetMix, Feedback, MinSweep, MaxSweep, Rate) - add chorus/flanger effect,
UPlayerNext.RemoveChorus() - remove chorus,
DryMix -  Dry (unaffected) signal mix [-2....+2]
WetMix -  Wet (affected) signal mix [-2....+2]
Feedback -  Output signal to feed back into input [-1....+1]
MinSweep -  Minimum delay in ms [0<..6000]
MaxSweep -  Maximum delay in ms [0<..6000]
Rate -  Rate in ms/s [0<..1000]
UPlayerNext.SetDistortion(Drive, DryMix, WetMix, Feedback, Volume) - add distortion effect,
UPlayerNext.RemoveDistortion() - remove distortion,
Drive -  Distortion drive [0....5]
DryMix -  Dry (unaffected) signal mix [-5..+5]
WetMix -  Wet (affected) signal mix [-5..+5]
Feedback -  Output signal to feed back into input [-1..+1]
Volume -  Distortion volume [0...+2]
UPlayerNext.SetEcho(DryMix, WetMix, Feedback,  Delay) - add echo/reverb effect,
UPlayerNext.RemoveEcho() - remove echo/reverb,
DryMix -  Dry (unaffected) signal mix [-2..+2]
WetMix -  Wet (affected) signal mix [-2..+2]
Feedback -  Output signal to feed back into input [-1..+1]
Delay -  Delay in seconds [0<...n]

UPlayerNext.RemoveAllEffects() - remove all added effects.

BPM slots

UPlayerNext.bpmEnable - enable BPM detection,
UPlayerNext.bpmBPM - get current BPM,
UPlayerNext.bpmPosition - beat trigger getting BPM value after a period of time (in seconds).
 

Effects description

Phaser

Phasers use an internal low frequency oscillator to automatically move notches in the frequency response up and down the frequency spectrum. An important difference between phasing and flanging is that phasers space these notches evenly across the frequency spectrum, while the notches in flanging and chorus are harmonically (musically) related. You don't hear the notches as such (because they are the frequencies that are removed). What you hear is the resulting frequency peaks between these notches. Phasing works by mixing the original signal with one that is phase shifted over the frequency spectrum. For example, a four stage phaser signal could be from 0 degrees at 100Hz, shifted to 720 degrees at 5kHz (these extremes are not quite possible practically, but are near enough to explain the effect). This is how the term phase shifter comes about. A 4 stage phaser has 2 notches with bass response, a central peak, and treble response. By using resonance to enhance the central peak, you can get a sound similar to an automatic wah. Using a phaser with lots of stages and setting the resonance high can give a sound similar to flanging, although they are really quite different.

The DryMix is the volume of input signal & the WetMix is the volume of delayed signal. The Feedback sets feedback of phaser. The Rate and Range control how fast and far the frequency notches move. The Rate is the rate of sweep in cycles per second, Range is the width of sweep in octaves. And the the Freq is the base frequency of sweep.

Examples

  Dry Wet Feedback Rate Range Freq
Phase shift 0.999 0.999 0.0 1.0 4.0 100.0
Slow invert phase shift with feedback 0.999 -0.999 -0.6 0.2 6.0 100.0
Basic phase 0.999 0.999 0.0 1.0 4.3 50.0
Phase w/ FB 0.999 0.999 0.6 1.0 4.0 40.0
Med. phase 0.999 0.999 0.0 1.0 7.0 100.0
Fast phase 0.999 0.999 0.0 1.0 7.0 400.0
Invert w/ invert FB 0.999 -0.999 -0.2 1.0 7.0 200.0
Tremolo Wah 0.999 0.999 0.6 1.0 4.0 60.0

Auto Wah

The effect implements the auto-wah by using a 4-stage phaser effect which moves a peak in the frequency response up and down the frequency spectrum by amplitude of input signal.

The DryMix is the volume of input signal & the WetMix is the volume of delayed signal. The Feedback sets feedback of auto wah (phaser). The Rate and Range control how fast and far the frequency notches move. The Rate is the rate of sweep in cycles per second, Range is the width of sweep in octaves. And the the Freq is the base frequency of sweep.

Examples

  Dry Wet Feedback Rate Range Freq
Slow Auto Wah 0.500 1.500 0.5 2.0 4.3 50.0
Fast Auto Wah 0.500 1.500 0.5 5.0 5.3 50.0
Hi Fast Auto Wah 0.500 1.500 0.5 5.0 4.3 500.0

Chorus

True vintage chorus works the same way as flanging. It mixes a varying delayed signal with the original to produce a large number of harmonically related notches in the frequency response. Chorus uses a longer delay than flanging, so there is a perception of "spaciousness", although the delay is too short to hear as a distinct slap-back echo. There is also little or no feedback, so the effect is more subtle.

The DryMix is the volume of input signal & the WetMix is the volume of delayed signal. The Feedback sets feedback of chorus. The Rate, MinSweep and MaxSweep control how fast and far the frequency notches move. The Rate is the rate of delay change in millisecs per sec, MaxSweep-MinSweep is the range or width of sweep in ms.

Examples

   Dry  Wet  Feedback Min Max  Rate
 Flanger  1.0  0.35  0.5  1.0  5.0  1.0
 Exaggerated chorus leads to multiple pitch shifted voices  0.7  0.25  0.5  1.0  200.0  50.0
 Motorcycle  0.9  0.45  0.5  1.0  100.0  25.0
 Devil  0.9  0.35  0.5  1.0  50.0  200.0
 Who say that there're not many voices?  0.9  0.35  0.5  1.0  400.0  200.0
 Back chipmunk  0.9  -0.2  0.5  1.0  400.0  400.0
 Water  0.9  -0.4  0.5   1.0  2.0  1.0
 This is the airplane  0.3  0.4  0.5   1.0  10.0  5.0

Distortion

Similar to Pre/Post Gain & Drive controls on amps. They were first introduced as a trick to added color to a guitar's tone. Usually produced back then by turning the amp all the way up, or slightly pulling out a tube from its socket. These tones are now today referred to as Overdrives. Today, there are an almost infinite variety of these effects, and they range in 3 classes: Distortions, Fuzz, and Overdrive. One common feature to mostly all of these types of pedals is a volume and drive (also noted as distortion, fuzz, gain, ...etc.). Overdrives are usually a sustain and volume boosting pedal. Used by more traditional rock and country bands. Next are the Distortions, which range from punk style to death metal screams. They are similar to Overdrives, but have more buzzing quality to them. Finally, there are the Fuzzes which are more distorted than distortions, but are more mellow and compressed sounding. Many pedals can be confused within these names, and some may be named other than what they are. Towards the end of this era, the back-to-back diode pair became popular as a technique to provide soft clipping (with germanium diodes) and hard clipping (with silicon diodes). Today, overdrive effects usually means soft clipping, where gain is reduced beyond the clipping point, while distortion usually means hard clipping, where the level is fixed beyond the clipping point. Distortion is a little harder sound, good for rock, while overdrive gives a more natural sound.

The Drive controls the amount of overdrive. The Volume to balance the effect volume with the bypassed level. It can also be used to boost the signal for solos. The DryMix is the volume of input signal & the WetMix is the volume of distorted signal. The Feedback sets feedback of distortion.

    Normal Sin Wave              Wave distorted by algorithm
                                     *
                                    * *
    ****                            * *
   *    *                           * *  *
  *      *                         *  * * *
 *        *                       *   * *  *
*          *                     *    * *   *
*          *                     *     *    *
------------*-------------       ------------*-------------
             *          *                     *     *    *
             *          *                     *    * *   *
              *        *                       *   * *  *
               *      *                         *  * * *
                *    *                           * *  *
                 ****                            * *
                                                 * *
                                                  *

Examples

  Drive Dry Wet Feedback Volume
Hard Distortion 1.0 0.0 1.0 0.0 1.0
Very Hard Distortion 5.0 0.0 1.0 0.1 1.0
Medium Distortion 0.2 1.0 1.0 0.1 1.0
Soft Distortion 0.0 -2.95 -0.05 -0.18 0.25

Echo/reverb

This is an echo effect that replays what you have played one or more times after a period of time. It's something like the echoes you might hear shouting against a canyon wall. For reverb effect enable feedback.

The DryMix is the volume of input signal & the WetMix is the volume of delayed signal. The Delay is the delay time in sec. The Feedback sets how much delay is feed back to the input (for repeating delays). 

Examples

  Dry Wet Feedback Delay
Small Echo 0.999 0.999 0.0 0.20
Many Echoes 0.999 0.999 0.7 0.50
Reverse Echoes 0.999 0.999 -0.7 0.80
Robotic Voice 0.500 0.800 0.5 0.10

 

Urbiscript example

// init module
loadModule("UPlayerNext");
var Global.playerNext = UPlayerNext.new();
// play a simple file
playerNext.Play("music.mp3"),
playerNext.position = 100;
playerNext.volume = 50;
echo(playerNext.vumeter);
// play from url
playerNext.Play("http://files.kusmierz.be/rmf/club.m3u"),
echo(playerNext.urlInfo); 
echo(playerNext.urlName); 
echo(playerNext.urlBitrate); 
echo(playerNext.urlTag);
// record
playerNext.StartRecord(0,"new_sound.wav");
sleep(5s);
playerNext.StopRecord();
// set effects
playerNext.SetEqualizer(2,-1,2); 
playerNext.RemoveEqualizer();
 
playerNext.SetAutoWah(0.5,1.5,0.5,5.0,5.3,50.0); 
playerNext.RemoveAutoWah();
 
playerNext.SetChorus(1.0,0.35,0.5,1.0,5.0,1.0);
playerNext.RemoveChorus();
// use tempo
playerNext.tempoEnable = true;
playerNext.Play("still.mp3"),
 
playerNext.tempoTempo=-4;
playerNext.tempoPitch=1;
// reverse
playerNext.tempoEnable = false;
playerNext.reverseEnable = true;
playerNext.Play("music.mp3"),
// bpm
playerNext.bpmEnable = true;
playerNext.Play("music.mp3"),
echo(playerNext.bpmBPM);
echo(playerNext.bpmPosition);

Download

LINK current

LINK v 2.11

 

 

EMYS and FLASH are Open Source and distributed according to the GPL v2.0 © Rev. 0.9.1, 15.05.2017

FLASH Documentation