electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Developers' Corner
Applying envelope to RP2040 PWM output
Post new topic   Reply to topic Moderators: DrJustice
Page 1 of 1 [2 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
Mickeyluv



Joined: Jan 18, 2022
Posts: 8
Location: UK

PostPosted: Mon Mar 24, 2025 9:40 am    Post subject: Applying envelope to RP2040 PWM output Reply with quote  Mark this post and the followings unread

I want to apply a simple AR envelope to the PWM output of the Hagiwo chord VCO V2. My thought is to use a variable 'envelope_level' which is an integer value (say, 0-511) that follows the attack and decay cycles.

Presumably the output levels are set by, for example;
pwm_set_chan_level(slice_num, PWM_CHAN_A, wavetable[(int)osc_progress[0]]/4+wavetable[(int)osc_progress[1]]/4+wavetable[(int)osc_progress[3]]/4+511);

How should the envelope be applied so that the output ranges from silent through to the original level?

I'm thinking that envelope_level could be normalised in the range 0 to 1 and used to multiply
wavetable[(int)osc_progress[0]]/4+wavetable[(int)osc_progress[1]]/4+wavetable[(int)osc_progress[3]]/4 before adding the 511 offset. Is this correct?


RP2040 Chord VCO V2.ino.txt
 Description:

Download (listen)
 Filename:  RP2040 Chord VCO V2.ino.txt
 Filesize:  25.15 KB
 Downloaded:  12 Time(s)

Back to top
View user's profile Send private message
Mickeyluv



Joined: Jan 18, 2022
Posts: 8
Location: UK

PostPosted: Tue Mar 25, 2025 10:07 am    Post subject: Reply with quote  Mark this post and the followings unread

Just done some experimenting and found that multiplying by envelope_level then dividing by 511 before adding 511 works fine.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: DrJustice
Page 1 of 1 [2 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Developers' Corner
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use