Add audio pan API

This commit is contained in:
Locria Cyber 2022-04-24 15:27:53 +02:00
parent 6d17b2c16b
commit 2c5854f8a3
No known key found for this signature in database
GPG Key ID: ED0D424AE4406330
1 changed files with 11 additions and 10 deletions

View File

@ -207,7 +207,7 @@ pub const Tone = struct {
/// / \
/// / \
pub const Volume = packed struct {
sustain : u8 = 100,
sustain : u8,
attack : u8 = 100,
pub fn is_valid(volume: @This()) bool {
@ -218,7 +218,8 @@ pub const Tone = struct {
pub const Flags = packed struct {
channel: Channel,
pulse_duty: DutyCycle,
pulse_duty: DutyCycle = 2,
pan: Pan = .both,
};
pub const Channel = enum(u2) {
@ -232,17 +233,17 @@ pub const Tone = struct {
@"1/8" = 0,
@"1/4" = 1,
@"1/2" = 2,
@"3/4" = 3,
};
/// Which stereo channel(s) to play audio in
pub const Pan = enum(u2) {
/// play audio in both stereo channels
both = 0,
left = 1,
right = 2,
};
};
pub const TONE_MODE1: u32 = 0;
pub const TONE_MODE2: u32 = 4;
pub const TONE_MODE3: u32 = 8;
pub const TONE_MODE4: u32 = 12;
pub const TONE_PAN_LEFT: u32 = 16;
pub const TONE_PAN_RIGHT: u32 = 32;
//
//
// Storage Functions