Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

foo

  • Loading branch information...
commit 749ecaacbe5b4941bcb79eac163684cd7cb995d4 1 parent 4441b0f
Alex McLean yaxu authored
Showing with 21 additions and 23 deletions.
  1. +7 −8 audio.c
  2. +1 −3 audio.h
  3. +2 −1  file.c
  4. +11 −11 server.c
15 audio.c
View
@@ -34,7 +34,7 @@ int queue_size(t_sound *queue) {
while (queue != NULL) {
result++;
queue = queue->next;
- if (result > 1024) {
+ if (result > 4096) {
printf("whoops, big queue\n");
break;
}
@@ -166,12 +166,13 @@ float formant_filter(float in, t_sound *sound, int channel) {
return res;
}
-extern int audio_play(double when, char *samplename, float offset, float duration, float speed, float pan, float velocity, int vowelnum, float start) {
+extern int audio_play(double when, char *samplename, float offset, float start, float end, float speed, float pan, float velocity, int vowelnum) {
int result = 0;
struct timeval tv;
t_sample *sample = file_get(samplename);
+
gettimeofday(&tv, NULL);
- printf("samplename: %s when: %f\n", samplename, when - (float) tv.tv_sec);
+ //printf("samplename: %s when: %f\n", samplename, when - (float) tv.tv_sec);
if (sample != NULL) {
//printf("got\n");
t_sound *new = (t_sound *) calloc(1, sizeof(t_sound));
@@ -191,15 +192,13 @@ extern int audio_play(double when, char *samplename, float offset, float duratio
new->offset = offset;
new->frames = new->sample->info->frames;
- new->duration = duration;
- printf("start: %f\n", start);
+
if (start > 0 && start <= 1) {
- printf("newpos: %f\n", new->position);
new->position = start * new->frames;
}
- if (new->duration < 1) {
- new->frames *= new->duration;
+ if (end > 0 && end < 1) {
+ new->frames *= end;
}
if (new->speed == 0) {
4 audio.h
View
@@ -16,8 +16,6 @@ typedef struct t_node {
float speed;
float pan;
float offset;
- float start;
- float duration;
float frames;
float velocity;
double formant_history[CHANNELS][10];
@@ -26,4 +24,4 @@ typedef struct t_node {
extern int audio_callback(int frames, float **buffers);
extern void audio_init(void);
-extern int audio_play(double when, char *samplename, float offset, float duration, float speed, float pan, float velocity, int vowelnum, float start);
+extern int audio_play(double when, char *samplename, float offset, float start, float end, float speed, float pan, float velocity, int vowelnum);
3  file.c
View
@@ -135,7 +135,8 @@ extern t_sample *file_get(char *samplename) {
}
else {
fix_samplerate(sample);
- sample->onsets = segment_get_onsets(sample);
+ sample->onsets = NULL;
+ //sample->onsets = segment_get_onsets(sample);
}
}
22 server.c
View
@@ -50,12 +50,12 @@ int play_handler(const char *path, const char *types, lo_arg **argv,
char *sample_name = strdup((char *) argv[2]);
float offset = argv[3]->f;
- float duration = argv[4]->f;
- float speed = argv[5]->f;
- float pan = argv[6]->f;
- float velocity = argv[7]->f;
- char *vowel_s = (char *) argv[8];
- float start = argv[9]->f;
+ float start = argv[4]->f;
+ float end = argv[5]->f;
+ float speed = argv[6]->f;
+ float pan = argv[7]->f;
+ float velocity = argv[8]->f;
+ char *vowel_s = (char *) argv[9];
int vowelnum = -1;
@@ -66,17 +66,17 @@ int play_handler(const char *path, const char *types, lo_arg **argv,
case 'o': case 'O': vowelnum = 3; break;
case 'u': case 'U': vowelnum = 4; break;
}
- printf("vowel: %s num: %d\n", vowel_s, vowelnum);
+ //printf("vowel: %s num: %d\n", vowel_s, vowelnum);
audio_play(when,
sample_name,
offset,
- duration,
+ start,
+ end,
speed,
pan,
velocity,
- vowelnum,
- start
+ vowelnum
);
return 0;
}
@@ -88,7 +88,7 @@ extern int server_init(void) {
//lo_server_thread_add_method(st, NULL, NULL, generic_handler, NULL);
- lo_server_thread_add_method(st, "/play", "iisfffffsf",
+ lo_server_thread_add_method(st, "/play", "iisffffffs",
play_handler,
NULL
);
Please sign in to comment.
Something went wrong with that request. Please try again.