예제 #1
0
파일: dev.cpp 프로젝트: rbtsx/AlloSomnium
    MyApp() : scene(BLOCK_SIZE) {
        speakerLayout = new SpeakerLayout();
        if (onLaptop) {
            cout << "Using 2 speaker layout" << endl;
            speakerLayout->addSpeaker(Speaker(0, 45, 0, 1.0, 1.0));
            speakerLayout->addSpeaker(Speaker(1, -45, 0, 1.0, 1.0));
        }
        else {
            cout << "Using 3 speaker layout" << endl;
            speakerLayout->addSpeaker(Speaker(0,   0, 0, 100.0, 1.0));
            speakerLayout->addSpeaker(Speaker(1, 120, 0, 100.0, 1.0));
            speakerLayout->addSpeaker(Speaker(2,-120, 0, 100.0, 1.0));
            //speakerLayout->addSpeaker(Speaker(3,   0, 0,   0.0, 0.5));
        }
        panner = new Vbap(*speakerLayout);
        panner->setIs3D(false); // no 3d!

        listener = scene.createListener(panner);
        listener->compile();
        for (int i = 0; i < 10; i++) {
            source[i].dopplerType(DOPPLER_NONE); // XXX doppler kills when moving fast!
            source[i].law(ATTEN_LINEAR);
            scene.addSource(source[i]);
        }
        panner->print();

        scene.usePerSampleProcessing(false);

        AudioDevice::printAll();

        audioIO().print();
        fflush(stdout);

        if (onLaptop) {
            cout << "we're on a laptop, so use normal, default audio hardware" << endl;
            initAudio(44100, BLOCK_SIZE);
        }
        else {
            cout << "we're on the mini, so we will try the TASCAM" << endl;
//      audioIO().device(AudioDevice("TASCAM"));
            audioIO().device(AudioDevice(29));
            initAudio(44100, BLOCK_SIZE, 4, 0);
        }
        cout << "GOT HERE" << endl;

        audioIO().print();
        fflush(stdout);
    }
예제 #2
0
	MyApp () :
	    audioScene(BLOCK_SIZE),
	    spatializer(speakerLayout)
	{
		initWindow();

		addSphere(graphics().mesh());
		graphics().mesh().generateNormals();
		for (int i = 0; i < 50; ++i) {
			source[i].freq(150 + random.uniform(-1, 1));
			audioScene.addSource(source[i]);
		}
		for (int i = 0; i < 50; ++i) {
			source[i + 50].freq(700 + random.uniform(-2, 2));
			audioScene.addSource(source[i + 50]);
		}
		for (int i = 0; i < 50; ++i) {
			source[i + 50].freq(1800 + random.uniform(-3, 3));
			audioScene.addSource(source[i + 100]);
		}
		gam::sampleRate(44100);
		audioIO().device(0);
		initAudio(44100, BLOCK_SIZE);
		listener = audioScene.createListener(&spatializer);
		listener->compile();

		for (int i = 0; i < 150; ++i) {
			double ft1 = data[i * 4];
			double ft2 = data[(i * 4)+ 1];
			double ft3 = data[(i * 4)+ 2];
			double ft4 = data[(i * 4)+ 3];
			double x = mapRange(ft1, 4.3, 7.9, -10.0, 10.0);
			double y = mapRange(ft2, 2.0, 4.4, -10.0, 10.0);
			double z = mapRange(ft3, 1.0, 6.9, -10.0, 10.0);
//			double size = mapRange(ft4, 0.1, 2.5, 0.25, 0.5);
			source[i].pos(x, y, z);
			source[i].farClip(2);
		}

		audioScene.usePerSampleProcessing(false);

	}