/*
          __
         / /_______________  ____  ___
        / __/ ___/ ___/ __ \/ __ \/ _ \
       / /_(__  ) /__/ /_/ / /_/ /  __/
       \__/____/\___/\____/ .___/\___/
                         /_/

    sound3.c
    setting a custom sound generating function
*/

#include <tscope.h>
#include <tscope/internal.h>

#define MAXTM mtt(3500)

struct {
    __int64 t1, t2;
    __int64 e1, e2;
} tmp;



// generate noise
unsigned char noise(__int64 sample)
{
    return ts_rint(256);
}

unsigned char sawtooth(__int64 sample)
{
    return sample % 256;
}

int main()
{
    ts_scrsize(SIZE2);
    ts_defkey(KEY_SPACE);

    // set the noise function as sound generating function
    ts_streamfunc(noise);

    // wait for a response
    ts_vsync(&tmp.t1, &tmp.e1);
    ts_printf_centre(0, 0, "press space");
    ts_rtstream(&tmp.t2, &tmp.e2, MAXTM);

    // draws the sound generated by the sound function
    ts_streamfunc(sawtooth);
    ts_drawsound();

    return 0;
}

END_OF_MAIN();


top
Persoonlijke pagina Universiteit GentTscope
Allegro | Cygwin | Gcc
© See license.html for copyright information