Exemple #1
0
void Sound::loadFromMemory(const char * data, int length){
    ALLEGRO_FILE * memory = al_open_memfile((void*) data, length, "r");
    this->data.sample = al_load_sample_f(memory, ".wav");
    al_fclose(memory);
    
    own = new int;
    *own = 1;
}
Exemple #2
0
ALLEGRO_SAMPLE *ioLoadSample(const char *filename) {

    unsigned int len;
    char *ext;
    ALLEGRO_FILE *fp = NULL;
    ALLEGRO_SAMPLE *smp = NULL;

    debugLog("io: load sample \"%s\"\n", filename);

    len = strlen(filename);
    ext = (char*)calloc(5, sizeof(char));
    strcpy(ext, filename + (len - 4));

    fp = ioOpenFile(filename);
    smp = al_load_sample_f(fp, ext);

    free(ext);

    debugLog("io: sample \"%s\" loaded\n", filename);

    return smp;
}
Exemple #3
0
    ALLEGRO_SAMPLE *open(const std::string filename) {

        debugArgs("io::sample", "Loading '%s'...", filename.data());

        void *rbuf;
        ALLEGRO_FILE *fp  = file::open(filename, &rbuf);
        ALLEGRO_SAMPLE *sample = NULL;

        if (fp != NULL) {
            std::string ext = filename.substr(filename.find_last_of("."));
            sample = al_load_sample_f(fp, ext.data());
            file::close(fp, &rbuf);
        } 
        
        if (sample) {
            debugArgs("io::sample", "Loaded '%s'", filename.data());

        } else {
            debugArgs("io::sample", "Failed to load '%s'", filename.data());
        }

        return sample;

    }