Added GoZenSound and VideoControl

This commit is contained in:
Mario Steele 2025-09-23 16:21:47 -05:00
parent c5058f8b84
commit f875d2ca0f
6 changed files with 107 additions and 1 deletions

View file

@ -0,0 +1,14 @@
using Godot;
using System;
public partial class GoZenAudio : Resource
{
public static byte[] GetAudioData() => ClassDB.ClassCallStatic("GoZenAudio", "get_audio_data").AsByteArray();
public static byte[] CombineData(byte[] audio1, byte[] audio2) => ClassDB.ClassCallStatic("GoZenAudio",
"combine_data", Variant.CreateFrom(audio1), Variant.CreateFrom(audio2)).AsByteArray();
public static byte[] ChangeDb(byte[] audio, float db) => ClassDB.ClassCallStatic("GoZenAudio", "change_db", Variant.CreateFrom(audio), Variant.CreateFrom(db)).AsByteArray();
public static byte[] ChangeToMono(byte[] audio) => ClassDB.ClassCallStatic("GoZenAudio", "change_to_mono", Variant.CreateFrom(audio)).AsByteArray();
}

View file

@ -0,0 +1 @@
uid://bsrbb6owyigx0

View file

@ -0,0 +1,84 @@
using Godot;
using System;
using Godot.NativeInterop;
public partial class VideoControl : Control
{
[Signal]
public delegate void FrameChangedEventHandler(int frame_nr);
[Signal]
public delegate void NextFrameCalledEventHandler(int frame_nr);
[Signal]
public delegate void VideoLoadedEventHandler();
[Signal]
public delegate void VideoEndedEventHandler();
[Signal]
public delegate void PlaybackStartedEventHandler();
[Signal]
public delegate void PlaybackPausedEventHandler();
[Signal]
public delegate void PlaybackReadyEventHandler();
public const float PLAYBACK_SPEED_MIN = 0.25f;
public const float PLAYBACK_SPEED_MAX = 4.0f;
[Export(PropertyHint.File)] public string Path;
[Export] public bool EnableAudio = true;
[Export] public bool EnableAutoPlay = false;
[Export(PropertyHint.Range, $"0.25,4.0,0.05")]
public float PlaybackSpeed = 1.0f;
[Export] public bool PitchAdjust = true;
[Export] public bool Loop = false;
[ExportGroup("Extra's")]
[Export] public ColorProfile ColorProfile = ColorProfile.Auto;
[Export] public bool Debug = false;
public GoZenVideo? Video;
public TextureRect VideoTexture = new TextureRect();
public AudioStreamPlayer AudioStream = new AudioStreamPlayer();
public bool IsPlaying = false;
public int CurrentFrame = 0;
private float _timeElapsed = 0.0f;
private float _timeFrame = 0.0f;
private int _skippedFrames = 0;
private int _rotation = 0;
private int _padding = 0;
private float _frameRate = 0.0f;
private int _frameCount = 0;
private Vector2I _resolution = Vector2I.Zero;
private ShaderMaterial _shaderMaterial;
private long[] _threads = [];
private AudioEffectPitchShift _audioPitchEffect = new AudioEffectPitchShift();
private ImageTexture _yTexture;
private ImageTexture _uTexture;
private ImageTexture _vTexture;
}
public enum ColorProfile
{
Auto,
Bt470,
Bt601,
Bt709,
Bt2020,
Bt2100
}

View file

@ -0,0 +1 @@
uid://clrgdf4tqpx4o