On 09/08/2013 11:08 PM, Brad Holland | Muzik Liberated wrote:
Hey Guys,
Since you are sox developers we thought that you may well be the best people to 
talk to.
We are looking for a small script (perhaps using sox) that scans a raw audio 
file and applies some modulation to the audio file which amplifies the content 
at specific points (when the signal is lower than -6db) and  continues to do 
this every time the sound does this throughout its decay.

This is to combat 8-bit sample artifacts when creating custom roms for a  drum 
machine. (Alesis HR-16). There is a special ASIC chip in this machine that 
detects a 6db spike in a waveform and the chip then turns down the gain -6db in 
essence, by keeping the amplitude of the waveform above the noise floor 
inherent in an 8-bit audio data you are able to achieve much higher fidelity in 
short decaying 'drum shot' type sounds.

We are a community of enthusiasts for the machine, although none of us could 
code anything like this. We'd be willing to pay/donate to the project or an 
individual to knock us up a bit of code to convert this..

A much more in-depth explanation of the process we need to accomplish is 
written in this post:http://www.burnkit2600.com/diy-sound-roms/

If someone is interested in helping us with this please get back to me!

Cheers
Brad

Hi Brad,

attached hack might do the trick.
If not, tell me, I'll have a closer look,
there might be bugs in there (just a quick
and dirty hack).

You can compile it, right? If you're using
windows you may need to change stuff in there
to handle binary files correctly.

Anyway, just tell me if something is wrong, whatever it is.

Regards,
Cédric.
#include <stdio.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <math.h>

int main(int n, char **v)
{
  char *infile;
  char *outfile;
  FILE *f;
  struct stat s;
  float *data;
  float *max;
  ssize_t size;
  ssize_t i;
  float gain;
  int up;
  float last;

  if (n != 3) {
    printf("gimme <input float mono file> <output float mono file>\n");
    return 1;
  }

  infile = v[1];
  outfile = v[2];

  if (stat(infile, &s)) { perror(infile); return 1; }
  size = s.st_size;

  data = malloc(size * sizeof(float)); if (data == NULL) abort();
  max = malloc(size * sizeof(float)); if (max == NULL) abort();

  f = fopen(infile, "rb"); if (f == NULL) { perror(infile); return 1; }
  fread(data, size, 4, f);
  fclose(f);

  max[size-1] = fabsf(data[size-1]);

  /* populate max */
  for (i = size-2; i >= 0; i--) {
    float m = fabsf(data[i]);
    if (m > max[i+1]) max[i] = m; else max[i] = max[i+1];
  }

  /* apply gain */
  gain = 1;
  up = 1;
  last = data[0];
  for (i = 0; i < size; i++) {
    data[i] *= gain;
    max[i] *= gain;
    if (up == 0 && data[i] > last) {
      /* local minimum */
      if (max[i] <= 0.5) gain *= 2;
    }
    if (data[i] > last) up = 1;
    else if (data[i] < last) up = 0;
    last = data[i];
  }

  f = fopen(outfile, "wb"); if (f == NULL) { perror(outfile); return 1; }
  fwrite(data, size, 4, f);
  fclose(f);

  return 0;
}
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

Reply via email to