예제 #1
0
ffstring TconvolverPage::getWavDesc(const char_t *flnm,int idc)
{
    TwavReader<float> wav(flnm,true);
    if (wav.empty()) {
        return _(idc,_l("invalid"));
    } else {
        char_t desc[256];
        wav.descriptionPCM(desc,256);
        return desc+ffstring(_l(", "))+ffstring::intToStr((int)wav[0].size())+_l(" samples");
    }
}
예제 #2
0
파일: main.cpp 프로젝트: eriser/wired
int testWaveFile()
{
    const wxString  stereoWaveFileName("StereoSample.wav");

    WaveFile    wav(stereoWaveFileName);

    TEST_ASSERT(wav.GetNumberOfChannels() == 2);
    TEST_ASSERT(wav.GetNumberOfFrames() == 82880);
    TEST_ASSERT(wav.GetSampleRate() == 44100);
    TEST_ASSERT(wav.GetFormat() == 65538);
    return 0;
}
예제 #3
0
void Game::loadSounds()
{
	string temp;
	bool changed = false;

	function<void (string, string)> loadSoundEffect = [&](string effectName, string defaultValue)
	{
		string effectFileName = saveData[effectName];

		if (effectFileName != "")
			soundEffects[effectName] = wav(effectFileName.c_str());
		else
		{
			changed = true;
			soundEffects[effectName] = wav((saveData[effectName] = defaultValue).c_str());
		}
	};

	loadSoundEffect("PickUpToolSound", "blip2.wav");
	loadSoundEffect("OpenDoorSound", "door.wav");
	loadSoundEffect("ChipDeathSound", "bummer.wav");
	loadSoundEffect("LevelCompleteSound", "ditty1.wav");
	loadSoundEffect("SocketSound", "chimes.wav");
	loadSoundEffect("BlockedMoveSound", "oof3.wav");
	loadSoundEffect("ThiefSound", "strike.wav");
	loadSoundEffect("SoundOnSound", "chimes.wav");
	loadSoundEffect("PickUpChipSound", "click3.wav");
	loadSoundEffect("SwitchSound", "pop2.wav");
	loadSoundEffect("SplashSound", "water2.wav");
	loadSoundEffect("BombSound", "hit3.wav");
	loadSoundEffect("TeleportSound", "teleport.wav");
	loadSoundEffect("TickSound", "click1.wav");
	
	if (changed)
		saveData.write();
}
예제 #4
0
void PADnoteParameters::export2wav(std::string basefilename)
{
    applyparameters(true);
    basefilename += "_PADsynth_";
    for(int k = 0; k < PAD_MAX_SAMPLES; ++k) {
        if(sample[k].smp == NULL)
            continue;
        char tmpstr[20];
        snprintf(tmpstr, 20, "_%02d", k + 1);
        std::string filename = basefilename + std::string(tmpstr) + ".wav";
        WavFile     wav(filename, synth->samplerate, 1);
        if(wav.good()) {
            int nsmps = sample[k].size;
            short int *smps = new short int[nsmps];
            for(int i = 0; i < nsmps; ++i)
                smps[i] = (short int)(sample[k].smp[i] * 32767.0f);
            wav.writeMonoSamples(nsmps, smps);
        }
    }
}
예제 #5
0
int main(int argc, char *argv[])
{
	CoInitializeEx(nullptr, COINIT_MULTITHREADED);

	try
	{
		audio.open(XAUDIO2_DEBUG_ENGINE);
		DMSG("open");
		Wav wav("D:\\openAL\\11k16bitpcm.wav");
		audio.stream(wav.getFormat());

		for (int i = 0; i < 2; ++i)
		{
			DMSG("submit buffer " << i);
			uint32_t size = wav.getSize();
			audio.appendBuffer(size);
			wav.read(audio.getBuffer(i), size);
			audio.submitBuffer(i, size);
		}

		wav.close();

		DMSG("sleep");
		Thread::sleep(10000);

		DMSG("stop");
		audio.stop();
	}
	catch (...)
	{
		std::cout << "error" << std::endl;
	}

	DMSG("close");
	audio.close();

	CoUninitialize();

	return 0;
}
예제 #6
0
파일: main.cpp 프로젝트: Jingzhe88/aquila
int main(int argc, char *argv[])
{
    std::string filename = getFile("test.wav");
    Aquila::WaveFile wav(20, 0.66);
    wav.load(filename);
    Aquila::MfccExtractor extractor(20, 10);
    Aquila::TransformOptions options;
    options.preemphasisFactor = 0.9375;
    options.windowType = Aquila::WIN_HAMMING;
    options.zeroPaddedLength = wav.getSamplesPerFrameZP();
    Aquila::ConsoleProcessingIndicator cpi;
    extractor.setProcessingIndicator(&cpi);

    std::cout << "Extracting MFCC features...\n";
    extractor.process(&wav, options);
    Aquila::TextFeatureWriter writer("feature.txt");
    extractor.save(writer);
    std::cout << "Finished!";

    std::cin.get();
    return 0;
}
예제 #7
0
void player_thread(void* parameter)
{
	rt_err_t result;
	struct player_request request;

	while(1)
	{
		/* get request from message queue */
		result = rt_mq_recv(player_thread_mq, (void*)&request,
			sizeof(struct player_request), RT_WAITING_FOREVER);
		if (result == RT_EOK)
		{
			switch (request.type)
			{
			case PLAYER_REQUEST_PLAY_SINGLE_FILE:
				if ((strstr(request.fn, ".mp3") != RT_NULL) ||
					(strstr(request.fn, ".MP3") != RT_NULL))
				{
					is_playing = RT_TRUE;
					player_notify_play();

				    /* get music tag information */
					mp3(request.fn);

					player_notify_stop();
					is_playing = RT_FALSE;
				}
				else if ((strstr(request.fn, ".wav") != RT_NULL) ||
					(strstr(request.fn, ".WAV") != RT_NULL))
				{
					is_playing = RT_TRUE;
					player_notify_play();
					wav(request.fn);
					player_notify_stop();
					is_playing = RT_FALSE;
				}
				else if ((strstr(request.fn, "http://") == request.fn ||
					(strstr(request.fn, "HTTP://") == request.fn )))
				{
					is_playing = RT_TRUE;
					player_notify_play();
					ice_mp3(request.fn, request.station);
					/* notfiy net buffer worker to stop */
					net_buf_stop_job();
					player_notify_stop();
					is_playing = RT_FALSE;
				}
				else if (strstr(request.fn, "douban://") == request.fn)
				{
					is_playing = RT_TRUE;
					player_notify_play();
					douban_radio(request.fn, request.station);

					/* notfiy net buffer worker to stop */
					net_buf_stop_job();
					player_notify_stop();
					is_playing = RT_FALSE;
				}
				break;
			}
		}
	}
}
예제 #8
0
파일: r3d.c 프로젝트: devonmpowell/r3d
void r3d_clip(r3d_poly* poly, r3d_plane* planes, r3d_int nplanes) {

	// direct access to vertex buffer
	r3d_vertex* vertbuffer = poly->verts; 
	r3d_int* nverts = &poly->nverts; 
	if(*nverts <= 0) return;

	// variable declarations
	r3d_int v, p, np, onv, vcur, vnext, vstart, 
			pnext, numunclipped;

	// signed distances to the clipping plane
	r3d_real sdists[R3D_MAX_VERTS];
	r3d_real smin, smax;

	// for marking clipped vertices
	r3d_int clipped[R3D_MAX_VERTS];

	// loop over each clip plane
	for(p = 0; p < nplanes; ++p) {

		// calculate signed distances to the clip plane
		onv = *nverts;
		smin = 1.0e30;
		smax = -1.0e30;
		memset(&clipped, 0, sizeof(clipped));
		for(v = 0; v < onv; ++v) {
			sdists[v] = planes[p].d + dot(vertbuffer[v].pos, planes[p].n);
			if(sdists[v] < smin) smin = sdists[v];
			if(sdists[v] > smax) smax = sdists[v];
			if(sdists[v] < 0.0) clipped[v] = 1;
		}

		// skip this face if the poly lies entirely on one side of it 
		if(smin >= 0.0) continue;
		if(smax <= 0.0) {
			*nverts = 0;
			return;
		}

		// check all edges and insert new vertices on the bisected edges 
		for(vcur = 0; vcur < onv; ++vcur) {
			if(clipped[vcur]) continue;
			for(np = 0; np < 3; ++np) {
				vnext = vertbuffer[vcur].pnbrs[np];
				if(!clipped[vnext]) continue;
				vertbuffer[*nverts].pnbrs[0] = vcur;
				vertbuffer[vcur].pnbrs[np] = *nverts;
				wav(vertbuffer[vcur].pos, -sdists[vnext],
					vertbuffer[vnext].pos, sdists[vcur],
					vertbuffer[*nverts].pos);
				(*nverts)++;
			}
		}

		// for each new vert, search around the faces for its new neighbors
		// and doubly-link everything
		for(vstart = onv; vstart < *nverts; ++vstart) {
			vcur = vstart;
			vnext = vertbuffer[vcur].pnbrs[0];
			do {
				for(np = 0; np < 3; ++np) if(vertbuffer[vnext].pnbrs[np] == vcur) break;
				vcur = vnext;
				pnext = (np+1)%3;
				vnext = vertbuffer[vcur].pnbrs[pnext];
			} while(vcur < onv);
			vertbuffer[vstart].pnbrs[2] = vcur;
			vertbuffer[vcur].pnbrs[1] = vstart;
		}

		// go through and compress the vertex list, removing clipped verts
		// and re-indexing accordingly (reusing `clipped` to re-index everything)
		numunclipped = 0;
		for(v = 0; v < *nverts; ++v) {
			if(!clipped[v]) {
				vertbuffer[numunclipped] = vertbuffer[v];
				clipped[v] = numunclipped++;
			}
		}
		*nverts = numunclipped;
		for(v = 0; v < *nverts; ++v) 
			for(np = 0; np < 3; ++np)
				vertbuffer[v].pnbrs[np] = clipped[vertbuffer[v].pnbrs[np]];
	}
}
int main()
{
//    Aquila::WaveFile wav("../../odonnell_you_go_girl.wav");
//    Aquila::WaveFile wav("../../harvey_super_cool.wav");
    //Aquila::WaveFile wav("../../miller_larry.wav");
//    Aquila::WaveFile wav("../../carlin_pc.wav");
//    Aquila::WaveFile wav("../../ireland_ouch.wav");
//    Aquila::WaveFile wav("../../mbi04w1.wav");
//    Aquila::WaveFile wav("../kabanos.wav");
//    Aquila::WaveFile wav("../../dbi03kaban.wav");
//    Aquila::WaveFile wav("../../dbi09w1short.wav");
//    Aquila::WaveFile wav("../../mbi04zapam.wav");
//    Aquila::WaveFile wav("../../mbi04poprzedni.wav");
//    Aquila::WaveFile wav("../../eastwood_lawyers.wav");
//    Aquila::WaveFile wav("../../mbi02w1.wav");
//    Aquila::WaveFile wav("../../mbi04w1.wav");
//    Aquila::WaveFile wav("../../dbi03w1s14.wav");
    Aquila::WaveFile wav("../../mwr35w1s14.wav");




    std::cout << "Filename: "           << wav.getFilename();
    std::cout << "\nLength: "           << wav.getAudioLength()     << " ms";
    std::cout << "\nSample frequency: " << wav.getSampleFrequency() << " Hz";
    std::cout << "\nChannels: "         << wav.getChannelsNum();
    std::cout << "\nByte rate: "        << wav.getBytesPerSec()/1024 << " kB/s";
    std::cout << "\nBits per sample: "  << wav.getBitsPerSample() << "b";
    std::cout << "\nSamples: "          << wav.getSampleFrequency()*wav.getAudioLength()/1000  << " samples\n";
//    for (int i = 0; i <wav.getSamplesCount() ; ++i) {
//        std::cout<<wav.sample(i)<<" ";
//    }

//    VAD *vad = new VADImp();
//    vad->detect(wav,1);
//
//    ResultPlotter *result = new ResultPlotter();
//    result->plot(wav);

    EnergyBasedDetector *detector = new EnergyBasedDetector();
    detector->detect(wav);

    Detector detectorSFF;
    detectorSFF.detect(wav);

    NewDetector detectorSFFNew;
    detectorSFFNew.detect(wav);



//    AquilaFft spectrum(wav.getSamplesCount());
//    const SampleType* x = wav.toArray();
//    SpectrumType mySpectrum;
//    mySpectrum = spectrum.fft(x);
//
//    //writing to file to plot results
//    system("touch spectrum");
//    //otwieram plik do zapisu
//    ofstream file2("spectrum");
//    if(file2){
//        for (size_t i = 0; i< mySpectrum.size() ; i++) {
//            file2 << mySpectrum.at(i) << endl;
//        }
//        file2.close();
//    } else{
//        cout<<"BLAD: nie mozna otworzyc pliku"<<endl;
//    }

    return 0;
}
예제 #10
0
    Handle::SfxHandle AudioWorld::loadAudioVDF(const VDFS::FileIndex& idx, const std::string& name)
    {
#ifdef RE_USE_SOUND
        if (!m_Context)
            return Handle::SfxHandle::makeInvalidHandle();

        std::string ucname = name;
        std::transform(ucname.begin(), ucname.end(), ucname.begin(), ::toupper);

        // m_SoundMap contains all the sounds with C_SFX script definitions
        Sound* snd = nullptr;
        Handle::SfxHandle h = m_SoundMap[ucname];
        if (!h.isValid())
        {
            // there are sounds which have no C_SFX defined
            Daedalus::GEngineClasses::C_SFX sfx;
            sfx.file = idx.hasFile(ucname) ? ucname : (ucname + ".wav");
            h = allocateSound(ucname, sfx);
            snd = &m_Allocator.getElement(h);
            m_SoundMap[ucname] = h;
        }
        else
        {
            snd = &m_Allocator.getElement(h);
            if (snd->m_Handle)  // already loaded
                return h;
        }

        // Load the audio-file from the VDF-archive
        std::vector<uint8_t> data;
        idx.getFileData(snd->sfx.file, data);

        if (data.empty())
            return Handle::SfxHandle::makeInvalidHandle();

        WavReader wav(&data[0], data.size());
        if (!wav.open() || !wav.read())
            return Handle::SfxHandle::makeInvalidHandle();

        alGenBuffers(1, &snd->m_Handle);

        ALenum error = alGetError();
        if (error != AL_NO_ERROR)
        {
            static bool warned = false;
            if (!warned)
            {
                LogWarn() << "Could not create OpenAL buffer: "
                          << AudioEngine::getErrorString(error);
                return Handle::SfxHandle::makeInvalidHandle();
            }
            return Handle::SfxHandle::makeInvalidHandle();
        }

        alBufferData(snd->m_Handle, AL_FORMAT_MONO16, wav.getData(), wav.getDataSize(), wav.getRate());
        error = alGetError();
        if (error != AL_NO_ERROR)
        {
            static bool warned = false;
            if (!warned)
            {
                LogWarn() << "Could not set OpenAL buffer data: "
                          << AudioEngine::getErrorString(error);
            }
            return Handle::SfxHandle::makeInvalidHandle();
        }

        // Load other versions, such as randomly played footstep variants
        loadVariants(h);

        m_SoundMap[name] = h;

        return h;
#else
        return Handle::SfxHandle::makeInvalidHandle();
#endif
    }
예제 #11
0
파일: vNd.c 프로젝트: devonmpowell/r3d
void rNd_split(rNd_poly* inpoly, rNd_poly** outpolys, rNd_real coord, rNd_int ax) {

	// naive split for now
	*outpolys[0] = *inpoly;
	*outpolys[1] = *inpoly;
	rNd_plane splane;
	memset(&splane, 0, sizeof(splane));
	splane.n.xyz[ax] = -1.0;
	splane.d = coord;
	rNd_clip(outpolys[0], &splane, 1);
	splane.n.xyz[ax] *= -1; 
	splane.d *= -1;
	rNd_clip(outpolys[1], &splane, 1);

#if 0

	// direct access to vertex buffer
	if(inpoly->nverts <= 0) return;
	rNd_int* nverts = &inpoly->nverts;
	rNd_vertex* vertbuffer = inpoly->verts; 
	rNd_int v, np, npnxt, onv, vcur, vnext, vstart, pnext, nright, cside;
	rNd_rvec newpos;
	rNd_int side[RND_MAX_VERTS];
	rNd_real sdists[RND_MAX_VERTS];

	// calculate signed distances to the clip plane
	nright = 0;
	memset(&side, 0, sizeof(side));
	for(v = 0; v < *nverts; ++v) {
			//sdists[v] = splane.d + rNd_dot(vertbuffer[v].pos, splane.n);
		sdists[v] = coord - vertbuffer[v].pos.xyz[ax];
		if(sdists[v] < 0.0) {
			side[v] = 1;
			nright++;
		}
	}

	// return if the poly lies entirely on one side of it 
	if(nright == 0) {
		*(outpolys[0]) = *inpoly;
		outpolys[1]->nverts = 0;
		return;
	}
	if(nright == *nverts) {
		*(outpolys[1]) = *inpoly;
		outpolys[0]->nverts = 0;
		return;
	}

	// check all edges and insert new vertices on the bisected edges 
	onv = inpoly->nverts;
	for(vcur = 0; vcur < onv; ++vcur) {
		if(side[vcur]) continue;
		for(np = 0; np < 3; ++np) {
			vnext = vertbuffer[vcur].pnbrs[np];
			if(!side[vnext]) continue;
			wav(vertbuffer[vcur].pos, -sdists[vnext],
				vertbuffer[vnext].pos, sdists[vcur],
				newpos);
			vertbuffer[*nverts].pos = newpos;
			vertbuffer[*nverts].pnbrs[0] = vcur;
			vertbuffer[vcur].pnbrs[np] = *nverts;
			(*nverts)++;
			vertbuffer[*nverts].pos = newpos;
			side[*nverts] = 1;
			vertbuffer[*nverts].pnbrs[0] = vnext;
			for(npnxt = 0; npnxt < 3; ++npnxt) 
				if(vertbuffer[vnext].pnbrs[npnxt] == vcur) break;
			vertbuffer[vnext].pnbrs[npnxt] = *nverts;
			(*nverts)++;
		}
	}

	// for each new vert, search around the faces for its new neighbors
	// and doubly-link everything
	for(vstart = onv; vstart < *nverts; ++vstart) {
		vcur = vstart;
		vnext = vertbuffer[vcur].pnbrs[0];
		do {
			for(np = 0; np < 3; ++np) if(vertbuffer[vnext].pnbrs[np] == vcur) break;
			vcur = vnext;
			pnext = (np+1)%3;
			vnext = vertbuffer[vcur].pnbrs[pnext];
		} while(vcur < onv);
		vertbuffer[vstart].pnbrs[2] = vcur;
		vertbuffer[vcur].pnbrs[1] = vstart;
	}

	// copy and compress vertices into their new buffers
	// reusing side[] for reindexing
	onv = *nverts;
	outpolys[0]->nverts = 0;
	outpolys[1]->nverts = 0;
	for(v = 0; v < onv; ++v) {
		cside = side[v];
		outpolys[cside]->verts[outpolys[cside]->nverts] = vertbuffer[v];
		side[v] = (outpolys[cside]->nverts)++;
	}

	for(v = 0; v < outpolys[0]->nverts; ++v) 
		for(np = 0; np < 3; ++np)
			outpolys[0]->verts[v].pnbrs[np] = side[outpolys[0]->verts[v].pnbrs[np]];
	for(v = 0; v < outpolys[1]->nverts; ++v) 
		for(np = 0; np < 3; ++np)
			outpolys[1]->verts[v].pnbrs[np] = side[outpolys[1]->verts[v].pnbrs[np]];
#endif
}