viewgit/index.php:465 Only variables should be passed by reference [2048]
viewgit/index.php:466 Non-static method GeSHi::get_language_name_from_extension() should not be called statically [2048]
#include "simple_audio.h" #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define PID 6.28318 sample sa_note_sample(sa_instrument* instrument, double frequency, double time) { // Calcolo il risultato della serie di Fourier al tempo time double value = instrument->fs->a_0; int i; for(i = 0; i < instrument->fs->cos_len; i++) { value += instrument->fs->cos_values[i] * cos(time * frequency * PID); } for(i = 0; i < instrument->fs->sin_len; i++) { value += instrument->fs->sin_values[i] * sin(time * frequency * PID); } // Ritorno il valore convertito a short int return sa_double_to_sample (value); } sample sa_double_to_sample(double s) { short int t = (short int) (32768 * s); sample ret; memcpy(&ret, &t, sizeof(sample)); return ret; } double sa_parse_note(char* note) { double base; double r2 = pow(2, 1/12.0); // Prima scala base = 440.0; if (strcmp(note, "A2")) { return 440.0; } if (strcmp(note, "B2")) { return base * pow(r2, 2); } if (strcmp(note, "C3")) { return base * pow(r2, 3); } if (strcmp(note, "D3")) { return base * pow(r2, 5); } if (strcmp(note, "E3")) { return base * pow(r2, 7); } if (strcmp(note, "F3")) { return base * pow(r2, 8); } if (strcmp(note, "G3")) { return base * pow(r2,10); } // Seconda scala base = 880.0; if (strcmp(note, "A3")) { return base; } if (strcmp(note, "B3")) { return base * pow(r2, 2); } if (strcmp(note, "C4")) { return base * pow(r2, 3); } if (strcmp(note, "D4")) { return base * pow(r2, 5); } if (strcmp(note, "E4")) { return base * pow(r2, 7); } if (strcmp(note, "F4")) { return base * pow(r2, 8); } if (strcmp(note, "G4")) { return base * pow(r2,10); } return base; } sample* sa_note(sa_instrument instrument, char* note, int len) { double frequency = sa_parse_note (note); int i; sample* s = (sample*) malloc(len * sizeof(sample)); for(i = 0; i < len; i++) { s[i] = sa_note_sample(&instrument, frequency, i / 44100.0); } return s; } sample sa_swap_bytes(sample s) { sample_b buf; unsigned char temp; buf.s = s; temp = buf.bytes[0]; buf.bytes[0] = buf.bytes[1]; buf.bytes[1] = temp; return buf.s; } int sa_write_samples(char* filename, sample* samples, int len) { FILE* handle; if( (handle = fopen(filename, "w")) == NULL ) { fprintf(stderr, "Impossibile aprire il file %s\n", filename); exit(EXIT_FAILURE); } int counter; sample buf; for(counter = 0; counter < len; counter ++) { buf = samples[counter]; if(sa_is_little_endian()) { buf = sa_swap_bytes(buf); } fwrite(&buf, sizeof(buf), 1, handle); fwrite(&buf, sizeof(buf), 1, handle); } fclose (handle); return EXIT_SUCCESS; } int sa_is_little_endian() { unsigned char endian[] = { 1, 0}; if( *((short*) endian) == 1) { return 1; } return 0; } int sa_is_big_endian() { unsigned char endian[] = { 1, 0}; if( *( (short*) endian) == 256) { return 1; } return 0; }