ponytracker/sources/instruments/instruments.c

62 lines
1.1 KiB
C
Raw Permalink Normal View History

/**
* @file instruments.c
*
* Implémentation de sample.h
*
* @version 1
* @author Guy
* @date Mai 2014
*/
#include "instruments.h"
2014-05-15 21:45:20 +02:00
void ajouterInstrument(Instrument* tab[], int i){
tab[i]=calloc(1,sizeof(Instrument));
strcpy(tab[i]->nom,"Nouvel instrument");
}
void supprimerInstrument(Instrument* tab[], int i){
free(tab[i]);
}
2014-05-21 18:08:47 +02:00
char* getChemin(Instrument* inst) {
return inst->sample->chemin;
}
int getVolumeInst(Instrument* inst) {
return inst->volume;
}
int getBalance(Instrument* inst) {
return inst->balance;
}
char* getNomInst(Instrument* inst) {
return inst->nom;
}
2014-05-21 18:08:47 +02:00
Sample* getSample(Instrument* inst) {
return inst->sample;
}
void setVolumeInst(Instrument* inst, int volume) {
inst->volume = volume;
}
2014-05-21 18:08:47 +02:00
void setBalanceInst(Instrument* inst, int balance) {
inst->balance = balance;
}
void setNomInst(Instrument* inst, char* nom) {
strcpy(inst->nom,nom);
}
2014-05-21 18:08:47 +02:00
void setSample(Instrument* inst, Sample* smpl){
inst->sample = smpl;
}
float rapportPitch(Instrument* inst, int note, int octave){
float freq = 440*pow(2,(octave-3)+(note-11)*(1.0/12.0));
return freq/(inst->sample->hauteur_ref);
}