Board index › Products › MIDIvampire

midivamp1 pitch control

13 posts · 26378 views

midivamp1 pitch control

by j.baars » Wed Oct 09, 2013 22:16 UTC
hello,
i would like to add a external pitch control, like a pot.

can that be done?

best,
J.Baars

Re: midivamp1 pitch control

by guest » Thu Oct 10, 2013 06:35 UTC
the pitch is set from the onboard oscillator, which also does the MIDI communication, so you can not change the oscillator without it messing up the MIDI. there are 2 other options: 1. send MIDI CC messages to do a frequency sweep, and then another one to turn frquency sweep off. this will pitch it down a bit, but only after note release, so its not a great option. 2. hack the code to add that MIDI CC control, or to read an analog pin and set the value based on that.

if you are interested in exploring option 2, i can give pointers. you will need an ISP programmer (i hear an arduino can be hacked to do this).

Re: midivamp1 pitch control

by j.baars » Wed Oct 23, 2013 21:35 UTC
well, i am very interested in option 2..

I would like to change the pitch with an external potentiometer.
I do know assembler coding, but that is rather rusty right now, it is probably some 30 jears ago i did my last assembler coding.
so some help here would be very much appreaciated...

best regards, Jeroen Baars

Re: midivamp1 pitch control

by guest » Thu Oct 24, 2013 21:03 UTC
ok, i can give pointers to get things going. probably the first thing to do would be to get a toolchain setup, and make sure you can change the code. luckily the ADC pins are broken out to the midi channel tabs, so you can attach there, which will be a lot easier than trying to solder directly to the IC. that potentially gives you 4 controllers you can add.

Re: midivamp1 pitch control

by j.baars » Thu Oct 24, 2013 23:31 UTC
ok, i do have avr studio, and lets say i will put the potentiometer to the adc3 input ( midi select8)
( i can add more potentiometers later, if i want to change more things)

best regards,
Jeroen Baars

Re: midivamp1 pitch control

by guest » Fri Oct 25, 2013 02:45 UTC
do you have an AVR ISP programmer?

go here
http://wiki.openmusiclabs.com/wiki/MidiVamp1
and download the avr studio project. i used avrstudio 4.13, so hopefully whatever they have these days is backwards compatible. load up the project and see if it compiles.

Re: midivamp1 pitch control

by j.baars » Mon Oct 28, 2013 13:42 UTC
yeps, i do have a programmer, and avr studio4 up and running .
it compiles perfectly.

best regards,
Jeroen Baars

Re: midivamp1 pitch control

by pianokeyjoe » Mon Oct 28, 2013 18:18 UTC
So from the answers here,I would not be able to pitch up or down each of the 8 midi vampire 1 modules I want to buy so I can make a very thick fat analog synth with detuned osc(x 8)?Or is the limitation only for physical pitch control OUTSIDE midi control CCs?

Re: midivamp1 pitch control

by guest » Mon Oct 28, 2013 20:35 UTC
j.baars wrote:yeps, i do have a programmer, and avr studio4 up and running .
it compiles perfectly.


awesome, probably the best thing to do first is make a small change, and upload the code to make sure the uploading process goes smoothly. a quick thing to change are the voices. this is done at the bottom of vamp1.asm

.org $0c00 ; voice2 table
.include "sine_table_2k_signed.inc" ; 8 bit, 2048 sample, sinewave


the .org statement says "put this code exactly here". so there are 16 of these, 1 for each voice. so you can change the voice by just changing the included file. so change

from
.include "sine_table_2k_signed.inc"
to
.include "square.inc"


then see if the sine voice now sounds like a square. one thing that might be a bit tricky, is that you need to apply power to the synth while programming. the easiest way to do this would be to just plug it into a synth with a midi cable, so it gets the phantom power. otherwise you can use an external 3V powersupply on the ISP header.

if that works, then we can start digging into getting the ADC setup and reading some values.

Re: midivamp1 pitch control

by guest » Mon Oct 28, 2013 20:38 UTC
pianokeyjoe wrote:So from the answers here,I would not be able to pitch up or down each of the 8 midi vampire 1 modules I want to buy so I can make a very thick fat analog synth with detuned osc(x 8)?Or is the limitation only for physical pitch control OUTSIDE midi control CCs?


it would have to be reprogrammed to accept external CC messages (or reprogrammed and rewired, as is being done here) to get the detune to work.

Re: midivamp1 pitch control

by j.baars » Mon Oct 28, 2013 20:53 UTC
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

Re: midivamp1 pitch control

by guest » Tue Oct 29, 2013 03:38 UTC
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:

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:

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:

.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

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:

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.

Re: midivamp1 pitch control

by j.baars » Wed Oct 30, 2013 10:45 UTC
ok, i will try all of this this weekend.
best regards,
Jeroen Baars