News:

SMF for DIYStompboxes.com!

Main Menu

DIY Peavey Sanpera footswitch

Started by swisher, June 14, 2023, 03:37:11 PM

Previous topic - Next topic

swisher

Hi guys!
I made footswitch for my Vypyr combo and programmed it in C (AVR). But I stuck on MIDI part. Does anyone know what code exactly is sending to combo from Sanpera I? I need commands for presets 1-4 only. Is it "program change" or "control change"? Does it sent 3 or 4 bytes at the same time?

Sweetalk

Did a quick google search and this came out, check it and see if that's what you need
http://zorkmids.com/?p=1425

swisher

I found it too (any few other sites). But I don't know how the string should look. There are few examples like this:
//MIDI COMMANDS
void patch(int instrument) {   
  Serial1.write((byte)0xC0);
  Serial1.write((byte)instrument);
}

void controller(int controller, int value) {
  Serial1.write((byte)0xB0);
  Serial1.write((byte)controller);
  Serial1.write((byte)value);
}
void noteOn(int key, int vel) {
  Serial1.write((byte)0x90);
  Serial1.write((byte)key);
  Serial1.write((byte)vel);
}

void noteOff(int key) {
  Serial1.write((byte)0x90);
  Serial1.write((byte)key);
  Serial1.write((byte)0x00);
}


I don't know what combination and what values should be used for 1 button which turn on 1 preset on VIP1.

potul

If you look at the code from the page Sweetalk posted, you will see it's using Program Change messages. Each button has a different program from 1 to 4.


      if (button1State == HIGH) {
        led1State = HIGH;
        patch(1);
      }
.....

void patch(int instrument) {   
  Serial1.write((byte)0xC0);
  Serial1.write((byte)instrument);
}

swisher

I don't know Arduino, I'm learning classic C. That's how I did reaction for pressed button:
if ( !switch_lock && !( PINC & SW1 ) ) {
    switch_lock = 50000;
    MIDI_send( 192, 4 );
}


But it's not working correct. It changes preset and then blocks anything for about 10 seconds, even on the amp. And after another few seconds it changes presets totally random.

garcho

  • SUPPORTER
"...and weird on top!"

swisher

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <stdlib.h>
#include <stdint.h>
#include <util/delay.h>

#include "midi.h"

#define SW1 (1<<PC3)
#define SW2 (1<<PC2)
#define SW3 (1<<PC1)
#define SW4 (1<<PC0)
#define SWITCHES ( SW1 | SW2 | SW3 | SW4 )

#define LED1 (1<<PD5)
#define LED2 (1<<PD6)
#define LED3 (1<<PD7)
#define LED4 (1<<PB0)


void MIDI_send( uint8_t midi_program );
void InitTimer ( void );

uint16_t switch_lock;
uint8_t switch_status=0;
uint8_t mode=1;

int main( void ) {

    DDRC  &= ~SWITCHES;
    PORTC |= SWITCHES;

    DDRD  |= ( LED1 | LED2 | LED3 );
    PORTD &= ( LED1 | LED2 | LED3 );

    DDRB  |= ( LED4 );
    PORTB &= ~( LED4 );

    sei();

    UART_Init( __UBRR );         

    while ( 1 ) {

        /* CLEAN CHANNEL */
        if ( !switch_lock && !( PINC & SW1 ) ) {
        switch_lock = 50000;
        switch_status=1;
        MIDI_send( 4-switch_status );
        }
        else if ( switch_lock && ( PINC & SW1 ) ) switch_lock++;

        /* LO CRUNCH */
if ( !switch_lock && !( PINC & SW3 ) ) {
switch_lock = 50000;
switch_status=2;
MIDI_send( 4-switch_status );
}
else if ( switch_lock && ( PINC & SW3 ) ) switch_lock++;

/* HI CRUNCH */
if ( !switch_lock && !( PINC & SW4 ) ) {
switch_lock = 50000;
switch_status=3;
MIDI_send( 4-switch_status );
}
else if ( switch_lock && ( PINC & SW4 ) ) switch_lock++;


        /* HEAVY CHANNEL */
        if ( !switch_lock && !( PINC & SW2 ) ) {
            switch_lock = 50000;
            switch_status=4;
            MIDI_send( 4-switch_status );
        }
        else if ( switch_lock && ( PINC & SW2 ) ) switch_lock++;


        // LEDS
        if ( switch_status==0 ) {
        PORTD &= ( LED1 | LED2 | LED3 );
        PORTB &= ~( LED4 );
        }
        else if ( switch_status==1 ) {
        PORTD |= ( LED1 );
        PORTD &= ~( LED2 | LED3 );
        PORTB &= ~( LED4 );
        }
        else if ( switch_status==2 ) {
        PORTD |= ( LED3 );
PORTD &= ~( LED1 | LED2 );
PORTB &= ~( LED4 );
        }
        else if ( switch_status==3 ) {
        PORTD &= ~( LED1 | LED2 | LED3 );
        PORTB |= ( LED4 );
        }
        else if ( switch_status==4 ) {
        PORTD |= ( LED2 );
PORTD &= ~( LED1 | LED3 );
PORTB &= ~( LED4 );
        }
    }
}

void MIDI_send( uint8_t midi_program ) {
    uart_putc( 0xC0 ); // 0xBn
    uart_putc( midi_program );     // 0-127
}