Skip to content

Add sample, sample_left, sample_right to FeMedia and FeMusic - #439

Open
oomek wants to merge 1 commit into
4.x.xfrom
feature/sample
Open

oomek wants to merge 1 commit into
4.x.xfrom
feature/sample

Conversation

@oomek

@oomek oomek commented Sep 5, 2026

Copy link
Copy Markdown
Owner
  • Add a 1kHz low-pass filter to attenuate aliasing caused by hight frequencies during visualisation

Example layout and assets:

fe.layout.width = 640
fe.layout.height = 480
fe.layout.preserve_aspect_ratio = true

local snap = fe.add_artwork( "snap", 0, 0, 640, 480 )

local lst = fe.add_listbox( 256, 0, 128, 480 )
lst.rows = 15;
lst.charsize = 10;
lst.bg_alpha = 255

local s11 = fe.add_image( "spkr1a.png", 120, 240, 200, 200 )
s11.anchor = Anchor.Centre
local s12 = fe.add_image( "spkr2.png", 120, 240, 200, 200 )
s12.anchor = Anchor.Centre
local s13 = fe.add_image( "spkr3.png", 120, 240, 200, 200 )
s13.anchor = Anchor.Centre

local s21 = fe.add_image( "spkr1b.png", 520, 240, 200, 200 )
s21.anchor = Anchor.Centre
local s22 = fe.add_image( "spkr2.png", 520, 240, 200, 200 )
s22.anchor = Anchor.Centre
local s23 = fe.add_image( "spkr3.png", 520, 240, 200, 200 )
s23.anchor = Anchor.Centre

local su1 = fe.add_surface( 0, 0, 256, 480, fe.monitors[0].width/3, fe.monitors[0].height )
su1.repeat = true
su1.clear = false
su1.blend_mode = BlendMode.Screen

local su2 = fe.add_surface( 384, 0, 256, 480, fe.monitors[0].width/3, fe.monitors[0].height )
su2.repeat = true
su2.clear = false
su2.blend_mode = BlendMode.Screen

local clr1 = su1.add_rectangle( 256, 0, 1, 960 )
clr1.set_rgb( 0, 0, 0 )
local dot1 = su1.add_rectangle( 256, 480 + 360 + 64, 1, 1 )
dot1.set_rgb( 255, 100, 255 )

local clr2 = su2.add_rectangle( 256, 0, 1, 960 )
clr2.set_rgb( 0, 0, 0 )
local dot2 = su2.add_rectangle( 256, 480 + 360, 1, 1 )
dot2.set_rgb( 100, 255, 100 )

fe.add_ticks_callback( "on_tick" )
function on_tick ( ttime )
{
    // Speakers
    s11.width = s11.height = fabs( snap.sample_left ) * 20 + 200
    s12.width = s12.height = fabs( snap.sample_left ) * 40 + 200

    s21.width = s21.height = snap.sample * 10 + 200
    s22.width = s22.height = snap.sample * 20 + 200

    // Graphs
    su1.subimg_x = ( su1.subimg_x + 1 ) % su1.subimg_width
    dot1.height = fabs( snap.sample ) * -256
    dot1.x = ( su1.subimg_width + su1.subimg_x - 1 ) % su1.subimg_width
    clr1.x = ( su1.subimg_width + su1.subimg_x - 1 ) % su1.subimg_width

    su2.subimg_x = ( su2.subimg_x + 1 ) % su2.subimg_width
    dot2.height = ( snap.sample ) * 128
    dot2.x = ( su2.subimg_width + su1.subimg_x - 1 ) % su1.subimg_width
    clr2.x = ( su2.subimg_width + su1.subimg_x - 1 ) % su1.subimg_width
}
spkr1a spkr1b spkr2 spkr3

- Add a 1kHz low-pass filter to attenuate aliasing caused by hight frequencies during visualisation
@oomek
oomek requested a review from Chadnaut September 5, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant