midivamp1 pitch control

Re: midivamp1 pitch control

Postby j.baars » Mon Oct 28, 2013 1:53 pm

ok, i will try this.
and powering the synth is not a problem, i can use the isp to power the synth.

best regards,
Jeroen Baars
j.baars
 
Posts: 6
Joined: Wed Oct 09, 2013 3:13 pm

Re: midivamp1 pitch control

Postby guest » Mon Oct 28, 2013 8:38 pm

after code uploading is verified to work, we can start developing the pitch bending code. the main issue here is how to implement it. a good pitch bender would use a multiply, and adjust the pitch by a certain percentage. this would make the shift amount consistent regardless of the note played. unfortunately, a multiply takes up a lot of clock cycles, and uses different registers.

since there isnt much free processing time, i would suggest starting with a constant pitch offset. this means that lower frequencies will appear to pitch more than higher frequencies. it might sound interesting, and will take a lot less computation.

a quick way to prototype this, is to steal another CC, and put your pitch shifting code in. for example, stealing the pitch sweep CC. look for these lines in vamp1.asm:

Code: Select all
mod13: ; frequency sweep

cpi r16,$0d
brne mod14
clr r16
subi r17,$40
sbc r16,r10
sts sweep_l,r17
sts sweep_h,r16
rjmp main ; go back to waiting


this code essentially does what we want already, it takes in the midi value, and converts it into a signed 16b value centered around 0. so values above 64 will pitch up, values below 64 will pitch down, and 64 will do nothing. we can just create a new variable, and reuse it:

Code: Select all
mod13: ; frequency sweep

cpi r16,$0d
brne mod14
clr r16
subi r17,$40
sbc r16,r10
;sts sweep_l,r17 ;these variables commented out
;sts sweep_h,r16
sts pitch_l,r17 ; new variables added
sts pitch_h,r16
rjmp main ; go back to waiting


you must create and initialize these variables as well. all of the variables are kept in vamp1_defs.inc. this just tells the compiler where in memory to look for your variable. it can just get tacked on at the end of the list:

Code: Select all
.equ pitch_l   = $0825
.equ pitch_h   = $0826


and initialization should go somewhere in the init: section at the top of vamp1.asm, probably the setup voices section

Code: Select all
clr r16
sts pitch_l,r16 ; set to 0
sts pitch_h,r16


now that pitch just has to get added in whenever a note plays. there are 4 voices, and it has to be added to each one. there are also 2 conditions, wether the note was decaying or not, so there are actually 8 different note on sequences. they are voice1_on:, voice1_on0:, voice2_on:, etc. here is an example of the modification needed:

Code: Select all
voice2_on: ; turn on voice2

lds r30,last_byte ; fetch note from lookup table
sts voice2,r30 ; store note number for turnoff sequence
lsl r30 ; adjust for 2byte fetch
ldi r31,$0c
lpm r16,z+ ; load it into the frequency register
lpm r17,z
lds r30,pitch_l ; fetch pitch bend value - new code
lds r31,pitch_h
add r16,r30 ; add in pitch value to current note - new code
adc r17,r31
cli
sts freq2_l,r16
sts freq2_h,r17
lds r16,pwm_start
sts pwm_depth2,r16 ; reset pwm depth
andi r23,$f3
ori r23,$04 ; set voice2 to attack
ori r24,$04 ; set voice2 trigger
sei
rjmp main ; go back to waiting


this currently only allows for the pitch to change when it is triggered, ie it will not act a 'bend' where you can modulate the note afterwards. that can be added later.
guest
Site Admin
 
Posts: 449
Joined: Thu May 20, 2010 11:58 pm

Re: midivamp1 pitch control

Postby j.baars » Wed Oct 30, 2013 3:45 am

ok, i will try all of this this weekend.
best regards,
Jeroen Baars
j.baars
 
Posts: 6
Joined: Wed Oct 09, 2013 3:13 pm

Previous

Return to MIDIvampire

Who is online

Users browsing this forum: No registered users and 1 guest


cron