head	1.6;
access;
symbols
	rel-0-2-1:1.5
	before_adj_struct:1.4.2.2
	jack:1.4.0.2
	rel-0-1-0:1.2
	rel-0-0-0:1.1;
locks; strict;
comment	@ * @;


1.6
date	2007.03.22.20.55.43;	author robertatwood;	state Exp;
branches;
next	1.5;

1.5
date	2006.04.05.21.53.36;	author robertatwood;	state Exp;
branches;
next	1.4;

1.4
date	2005.08.20.18.31.55;	author robertatwood;	state Exp;
branches
	1.4.2.1;
next	1.3;

1.3
date	2005.08.20.18.26.42;	author robertatwood;	state Exp;
branches;
next	1.2;

1.2
date	2005.04.03.20.05.39;	author robertatwood;	state Exp;
branches;
next	1.1;

1.1
date	2004.04.16.11.36.56;	author robertatwood;	state Exp;
branches;
next	;

1.4.2.1
date	2005.12.28.01.34.16;	author robertatwood;	state Exp;
branches;
next	1.4.2.2;

1.4.2.2
date	2005.12.28.16.13.35;	author robertatwood;	state Exp;
branches;
next	1.4.2.3;

1.4.2.3
date	2006.01.04.02.31.33;	author robertatwood;	state Exp;
branches;
next	;


desc
@@


1.6
log
@Updated GPL text to reflect new address of Free Software foundation
Prepare to move repository to savannah.nongnu.org
@
text
@/**************************************************************
This file is part of the Variseq program.
Variseq -- a variable pitch and step sample sequencer
Copyright (C) 2004  Robert Atwood r.atwood (at) imperial (dot) ac (dot) uk

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 
See the file COPYING for more information
**************************************************************/


#ifndef SAMPLES_H
#define SAMPLES_H
#define NAMELENGTH (100)
#include <string.h>
#include <malloc.h>
#include "constants.h"
#include "mysound.h"

extern void init_noteratio( double ** noteratio,int ntones );
typedef struct adj_struct{
	int type;
	int bars;
} Adj;


class samples{
   public:
   int nsamples;
   int ntones;
   double * noteratio;
   Adj * adj;
   char ** samplenames;
   sbuf * orig_samples;
   sbuf *** str_samples; 
   int *** used;

   samples(){
      init_samples(12);
   };
   samples(int n){
      init_samples(n);
   };
   void init_samples(int n){
      nsamples=0;
      orig_samples = NULL;
      ntones=n;
      str_samples  = NULL; //(sbuf ***) calloc(N_OCT, sizeof (sbuf **));
      used = NULL; //(int ***) calloc(N_OCT,sizeof(int **));
      init_noteratio(&noteratio,ntones);
      samplenames=NULL;
      adj = NULL;

  }
      
   ~samples(){};


   void save_samples(FILE * fp);
   void read_samples(FILE*fp);
   void setadj(int n, int b,int t){
      #ifndef NOPRINT
      printf("%s bars %i type %i\n",__func__,b,t);
      #endif
      adj[n].bars = b;
      adj[n].type = t;
   }
      

      

   void add_sample(sbuf * newsample,const char * name);
   void replace_sample(sbuf * newsample,const char * name,int whichrepl);
   void add_octave(int oct,int this_sample){
      *(*(used + this_sample) + oct) = (int *) calloc(ntones+1,sizeof(int ));
      *(*(str_samples + this_sample) + oct) = (sbuf *) calloc(ntones+1,sizeof(sbuf));
   }
   void stretch(int oct,int samplenum,int notenum);
   sbuf * get_note(int samplenum,int oct, int notenum);
};

#endif


/* $Id: samples.h,v 1.5 2006/04/05 21:53:36 robertatwood Exp $ */
@


1.5
log
@Jack version is the main branch now
@
text
@d18 1
a18 1
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
d22 1
d96 1
a96 1
/* $Id: samples.h,v 1.4.2.3 2006/01/04 02:31:33 robertatwood Exp $ */
@


1.4
log
@oops. checked in wrong
missing initialization in sample class
@
text
@d31 5
d42 1
d62 1
d71 8
d83 1
d95 1
a95 1
/* $Id: samples.h,v 1.3 2005/08/20 18:26:42 robertatwood Exp $ */
@


1.4.2.1
log
@Began sample-replace segment
@
text
@a67 1
   void replace_sample(sbuf * newsample,const char * name);
d79 1
a79 1
/* $Id: samples.h,v 1.4 2005/08/20 18:31:55 robertatwood Exp $ */
@


1.4.2.2
log
@Checkpoint-problem with sample table address
@
text
@d68 1
a68 1
   void replace_sample(sbuf * newsample,const char * name,int whichrepl);
d80 1
a80 1
/* $Id: samples.h,v 1.4.2.1 2005/12/28 01:34:16 robertatwood Exp $ */
@


1.4.2.3
log
@Sample scramblizer adjusters added
@
text
@a30 5
typedef struct adj_struct{
	int type;
	int bars;
} Adj;

a36 1
   Adj * adj;
a55 1
      adj = NULL;
a63 8
   void setadj(int n, int b,int t){
      #ifndef NOPRINT
      printf("%s bars %i type %i\n",__func__,b,t);
      #endif
      adj[n].bars = b;
      adj[n].type = t;
   }
      
d80 1
a80 1
/* $Id: samples.h,v 1.4.2.2 2005/12/28 16:13:35 robertatwood Exp $ */
@


1.3
log
@Added a save/restore workspace function
Added window to display names of samples
@
text
@d55 1
d79 1
a79 1
/* $Id: samples.h,v 1.3 2005/08/20 18:23:08 robert Exp $ */
@


1.2
log
@Changed the buffer writing so that samples extend into unused notes.
Altered file choose usage to correctly use the FLTK chooser
@
text
@d24 1
d37 1
a59 22
   void add_sample(sbuf * newsample){
      int this_sample = nsamples;
      nsamples ++;
      orig_samples = (sbuf *)realloc(orig_samples,nsamples * sizeof(sbuf));
      /* store the original in the table of original samples */
      init_sbuf(orig_samples + this_sample,44100);
      copy_sbuf((orig_samples + this_sample) , newsample);

      /* create the table for the stretched samples */
      /* generated from the new sample*/
      used = (int ***) realloc(used,nsamples * sizeof(int **));
      str_samples = (sbuf ***) realloc(str_samples,nsamples * sizeof(sbuf **));

      *(used + this_sample) = (int **) calloc(N_OCT, sizeof (int *));
      *(str_samples + this_sample) = (sbuf **) calloc(N_OCT, sizeof (sbuf *));


      /* for the default octave */
      add_octave(D_OCT,this_sample);
      /* add the unstretched sample */
      stretch(this_sample,D_OCT,0);
   };
d61 6
a70 1

d72 1
a72 38

   sbuf * get_note(int samplenum,int oct, int notenum){
      if (used == NULL) return(NULL);
      if (samplenum >= nsamples) return(NULL);


      if ( (* ( *(used+samplenum) +oct)) == NULL ) add_octave(oct,samplenum);

      int * thisused = (* ( *(used+samplenum) +oct));
      sbuf * thisbuf = *(*(str_samples+samplenum)+oct);

      if (orig_samples + samplenum == NULL) return (NULL);

      if (!thisused[notenum]){
         stretch(samplenum,oct,notenum);
      }
      return(thisbuf + notenum);
   };

   #ifdef JUNK
   sbuf * get_note(int samplenum, int notenum){
      if (used == NULL) return(NULL);
      if (samplenum >= nsamples) return(NULL);
      int * thisused = used[samplenum];
      sbuf * thisbuf = str_samples[samplenum];

      if (orig_samples + samplenum == NULL) return (NULL);
      if (samplenum >= nsamples) return (NULL);

      if (!thisused[notenum]){
         stretch(samplenum,notenum);
      }
      return(thisbuf + notenum);
   };
   #endif

       

d78 1
a78 1
/* $Id: samples.h,v 1.1.1.1 2004/05/23 20:29:59 robert Exp $ */
@


1.1
log
@Initial version uploaded to Sourceforge
@
text
@d130 1
a130 1
/* $Id: samples.h,v 1.4 2004/04/13 09:39:00 robert Exp $ */
@

