[ecasound] Ecasound for Beatmatching

From: Mason Fischer <moocowmason@email-addr-hidden>
Date: Sat Oct 03 2009 - 22:58:26 EEST

Hello list!
                I am a first time poster trying to get help using
ecasound for beatmatching (http://en.wikipedia.org/wiki/Beatmatching).
When I am finished I would like to be able to control how fast a track
is playing in real time by the frequency of a key press. Basically, I
want to sync a key press to the downbeat of a song: the faster I press
the key the faster the song plays. Then I will be able to fade into a
different song. I know that time stretching in real time is very
difficult computationally. What I plan to do is pre-generate many
files at different speeds using
rubberband(http://www.breakfastquay.com/rubberband/). When I "speed
the song up" I will just switch to a faster version of the track and
set the position to the same place in the song. I currently have a
mock up of the program which only has two speeds which you can toggle
by pressing enter. It is working however there is a slight pause after
the switch. Reading the list makes me think that I need
"sample-accurate looping"
(http://www.eca.cx/ecasound-list/2005/09/0028.html), however the file
type is wav which i think has this.

My questions for the list:
1. Is beatmatching going to be possible?
2. Is there a better approach?
3. Any ideas about how to remove this small pause.
4. Suggestions on my code are appreciated.

Thanks for your time!

   -Mason Fischer

//the slower track can be generated with rubberband -T140:120
dylan.wav dylan_140.wav
#include <stdio.h>
#include <unistd.h>
#include <ecasoundc.h>
void set_speed(float old_bpm,float bpm);

int main(int argc, char *argv[])
  int ch;
  int speed=1;

  eci_command("cs-add play_chainsetup");

  eci_command("c-add 1st_chain");
  eci_command("ai-add /home/masonf/eca/dylan.wav");

  // Load a version of the track at 140 bpm and mute it
  eci_command("c-add 2nd_chain");
  eci_command("ai-add /home/masonf/eca/dylan_140.wav");

  eci_command("c-select 1st_chain,2nd_chain");
  eci_command("ao-add /dev/dsp");

  while ((ch = getchar()) != EOF){
    // When the user types a key we toggle the speed


// Toggles which track is playing
// And sets the position accordingly

void set_speed(float old_bpm,float bpm){
  float pos=0;
  char command[100];

  eci_command("c-select 1st_chain");
  pos = eci_last_float();
  eci_command("c-select 2nd_chain");

  // Set the posisiton proportional to the chnage in bpm
  // For example when bpm is slowed the postiton should be later

  sprintf(command,"cs-set-position %3f",pos*(bpm/old_bpm));

  // toggle chains
  eci_command("c-select 1st_chain");

/* Local Variables: */
/* compile-command:"gcc -o eca ./eca.c `libecasoundc-config --cflags
--libs`&& ./eca" */
/* End: */

Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
Ecasound-list mailing list
Received on Sun Oct 4 00:15:02 2009

This archive was generated by hypermail 2.1.8 : Sun Oct 04 2009 - 00:15:02 EEST