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 
go to the radio page Live at electro-music.com radio 1 Please visit the chat
  host / artist show at your time
today> Modulator ESP Adventures In Sound
 Forum index » DIY Hardware and Software » Arduino
Arduino wavetable synthesis: Implementing an envelope.
Post new topic   Reply to topic
Page 1 of 1 [3 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
mubase



Joined: Mar 24, 2011
Posts: 117
Location: London UK
Audio files: 5

PostPosted: Sat Apr 25, 2015 5:19 am    Post subject: Arduino wavetable synthesis: Implementing an envelope. Reply with quote  Mark this post and the followings unread

Hi everyone. Smile
I am going a bit nuts trying to implement a simple decay to a wavetable synth I am working on using an ATXmega board and the Arduino IDE.
I can output a sine wavetable through the DAC quite easily. I use a calculated wavetable in an array of 256 values with a maximum value of 4095 as the DAC is 12 bits.
I can then use an accumulator and phase incrementer to get a wide frequency scale.
The output from the dac is done inside a timer overflow IRQ with a sample rate of around 31250Hz.
I would like to know how to implement an envelope. A simple decaying envelope to start with. So, say, I press a button and on button press detect, start the sound and decay. I want to do it using another wavetable containing a simple ramp wave to start with. Can some one explain to me how I would go about this?

The basic snippet of code that is playing the wave looks like this:
Code:
 accumulator += accumulatorSteps; /* advance accumulator */
      waveStep =( accumulator>>8);
output=(sine[waveStep]);
dac.write(output);//*decay[d]));


accumulator steps is the value of the frequency.


Thanks,
Steve>S

_________________
There's a crack in everything...Thats how glue manufacturers make a living.
Back to top
View user's profile Send private message
elmegil



Joined: Mar 20, 2012
Posts: 2179
Location: Chicago
Audio files: 16

PostPosted: Sat Apr 25, 2015 10:03 am    Post subject: Reply with quote  Mark this post and the followings unread

Multiplication Smile

Seriously; you'll need to scale the result appropriately, but that's really what is going on.

PS: Make sure you use integer math as much as possible; probably would want to pre-scale your wavetables.
Back to top
View user's profile Send private message
mubase



Joined: Mar 24, 2011
Posts: 117
Location: London UK
Audio files: 5

PostPosted: Fri May 01, 2015 4:51 am    Post subject: Arduino wavetable synthesis: Imple.. :SOLVED Reply with quote  Mark this post and the followings unread

Hi Elmegil. Very Happy

Yep. Thanks. My problem was scaling.
All working well now.
Also, I've migrated from xmega to stm32f4 on Arduino IDE. So much faster and nicer.
I'm now doing experiments with rudimentary (and i say RUDIMENTARY) synchronous granular synthesis. Smile

_________________
There's a crack in everything...Thats how glue manufacturers make a living.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic
Page 1 of 1 [3 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 » Arduino
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