Пример #1
0
 static void Main(string[] args)
 {
     using (var rhvoice = new RHVoice())
     {
         Console.WriteLine($"RHVoice version: {rhvoice.GetVersion()}");
         Console.WriteLine($"Voices available: {rhvoice.GetVoiceCount()}");
         var voices = rhvoice.GetVoices();
         foreach (var voice in voices)
         {
             Console.WriteLine(voice.Language);
             Console.WriteLine(voice.Name);
             Console.WriteLine(voice.Gender);
         }
         Console.WriteLine($"Profiles available: {rhvoice.GetVoiceProfilesCount()}");
         var profiles = rhvoice.GetVoiceProfiles();
         foreach (var profile in profiles)
         {
             Console.WriteLine(profile);
         }
         var p = new SynthParams();
         p.VoiceProfile = "Aleksandr";
         p.RelativeRate = 3.0;
         string msg;
         while ((msg = Console.ReadLine()) != "exit")
         {
             rhvoice.Speak(msg, p, false);
         }
     }
 }
Пример #2
0
    void OnWaveShapeSelected(bool value)
    {
        // Ignore if this is a negative event (eg. not the selected toggle).
        // Otherwise, we will handle duplicate events.
        if (!value)
        {
            return;
        }
        SynthParams synthParams = soundEffect.content.synthParams;

        if (ui.sineToggle.isOn)
        {
            synthParams.waveShape = SynthWaveShape.SINE;
        }
        else if (ui.squareToggle.isOn)
        {
            synthParams.waveShape = SynthWaveShape.SQUARE;
        }
        else if (ui.triangleToggle.isOn)
        {
            synthParams.waveShape = SynthWaveShape.TRIANGLE;
        }
        else if (ui.noiseToggle.isOn)
        {
            synthParams.waveShape = SynthWaveShape.NOISE;
        }
        PutAndPreviewSoundEffect();
    }
Пример #3
0
    private void UpdateWidgetsFromModel()
    {
        SynthParams synthParams = soundEffect.content.synthParams;

        ui.nameField.text = soundEffect.name;

        // Remove listeners before setting - we don't want to receive an event from programmatic set
        ui.sineToggle.onValueChanged.RemoveListener(OnWaveShapeSelected);
        ui.triangleToggle.onValueChanged.RemoveListener(OnWaveShapeSelected);
        ui.noiseToggle.onValueChanged.RemoveListener(OnWaveShapeSelected);
        ui.squareToggle.onValueChanged.RemoveListener(OnWaveShapeSelected);

        ui.sineToggle.isOn     = synthParams.waveShape == SynthWaveShape.SINE;
        ui.triangleToggle.isOn = synthParams.waveShape == SynthWaveShape.TRIANGLE;
        ui.noiseToggle.isOn    = synthParams.waveShape == SynthWaveShape.NOISE;
        ui.squareToggle.isOn   = synthParams.waveShape == SynthWaveShape.SQUARE;

        ui.sineToggle.onValueChanged.AddListener(OnWaveShapeSelected);
        ui.triangleToggle.onValueChanged.AddListener(OnWaveShapeSelected);
        ui.squareToggle.onValueChanged.AddListener(OnWaveShapeSelected);
        ui.noiseToggle.onValueChanged.AddListener(OnWaveShapeSelected);

        ui.pitchEditor.SetSampleValues(synthParams.pitch);
        ui.volumeEditor.SetSampleValues(synthParams.volume);
        ui.playbackSpeedSlider.SetValue(synthParams.speed);

        ui.spatializedToggle.onValueChanged.RemoveListener(OnSpatializedChanged);
        ui.spatializedToggle.isOn = soundEffect.content.spatialized;
        ui.spatializedToggle.onValueChanged.AddListener(OnSpatializedChanged);
    }
Пример #4
0
        private void BindParams(SynthParams value)
        {
            SelectedWaveShape = value.WaveShape;
            valAttackTime.Value = value.AttackTime;
            valChangeAmount.Value = value.ChangeAmount;
            valChangeSpeed.Value = value.ChangeSpeed;
            valDecayTime.Value = value.DecayTime;
            valDeltaSlide.Value = value.DeltaSlide;
            valDutySweep.Value = value.DutySweep;
            valHpfCutoff.Value = value.HighPassFilterCutoff;
            valHpfSweep.Value = value.HighPassFilterCutoffSweep;
            valLpfCutoff.Value = value.LowPassFilterCutoff;
            valLpfSweep.Value = value.LowPassFilterCutoffSweep;
            valLpfResonance.Value = value.LowPassFilterResonance;
            valMinFrequency.Value = value.MinFrequency;
            valPhaserOffset.Value = value.PhaserOffset;
            valPhaserSweep.Value = value.PhaserSweep;
            valSlide.Value = value.Slide;
            valSquareDuty.Value = value.SquareDuty;
            valStartFrequency.Value = value.StartFrequency;
            valSustainPunch.Value = value.SustainPunch;
            valSustainTime.Value = value.SustainTime;
            valVibratoDepth.Value = value.VibratoDepth;
            valVibratoSpeed.Value = value.VibratoSpeed;

            //// TODO: handle separately?
            //valRepeatSpeed.Value = value.RepeatSpeed;
            //valVolume.Value = value.MasterVolume;

            txtSerailized.Text = value.Serialize();
        }
Пример #5
0
    // Other types of content can be added here in the future.

    // Creates a SoundEffectContent based on synth parameters.
    public static SoundEffectContent NewWithSynthParams(SynthParams synthParams)
    {
        SoundEffectContent content = new SoundEffectContent();

        content.effectType  = SoundEffectType.Synthesized;
        content.synthParams = synthParams;
        content.spatialized = true;
        return(content);
    }
Пример #6
0
    public static SynthParams GetDefaults()
    {
        SynthParams synthParams = new SynthParams();

        synthParams.waveShape = SynthWaveShape.SQUARE;
        synthParams.speed     = SPEED_MAX / 2;
        synthParams.volume    = new int[NUM_SLICES];
        synthParams.pitch     = new int[NUM_SLICES];
        for (int i = 0; i < NUM_SLICES; i++)
        {
            synthParams.volume[i] = VOLUME_MAX;
            synthParams.pitch[i]  = PITCH_MAX / 2;
        }
        return(synthParams);
    }
Пример #7
0
 public ClipSynthesizer(SynthParams synthParams)
 {
     this.synthParams = synthParams;
     Synthesize();
 }
Пример #8
0
    void OnCreateNewClicked()
    {
        // TODO: in the future, we will want to ask what kind of sound effect the user
        // wants to create. For now the only type is synthesized sound effects, so
        // that's what we create:
        SoundEffect effect = new SoundEffect(System.Guid.NewGuid().ToString(),
                                             GetRandomSoundName(), SoundEffectContent.NewWithSynthParams(SynthParams.GetDefaults()));

        soundEffectSystem.PutSoundEffect(effect);
        foreach (ScrollingListItemUI item in listItems)
        {
            if (item.name == effect.id)
            {
                SetSelectedSound(item);
                return;
            }
        }
    }