Ejemplo n.º 1
0
TEST(API, TestFp) {
	std::vector<short> data = LoadAudioFile("data/test_stereo_44100.raw");

	ChromaprintContext *ctx = chromaprint_new(CHROMAPRINT_ALGORITHM_TEST2);
	ASSERT_NE(nullptr, ctx);
	SCOPE_EXIT(chromaprint_free(ctx));

	ASSERT_EQ(1, chromaprint_get_num_channels(ctx));
	ASSERT_EQ(11025, chromaprint_get_sample_rate(ctx));

	ASSERT_EQ(1, chromaprint_start(ctx, 44100, 1));
	ASSERT_EQ(1, chromaprint_feed(ctx, data.data(), data.size()));

	char *fp;
	uint32_t fp_hash;

	ASSERT_EQ(1, chromaprint_finish(ctx));
	ASSERT_EQ(1, chromaprint_get_fingerprint(ctx, &fp));
	SCOPE_EXIT(chromaprint_dealloc(fp));
	ASSERT_EQ(1, chromaprint_get_fingerprint_hash(ctx, &fp_hash));

	EXPECT_EQ(std::string("AQAAC0kkZUqYREkUnFAXHk8uuMZl6EfO4zu-4ABKFGESWIIMEQE"), std::string(fp));
	ASSERT_EQ(3732003127, fp_hash);
}
Ejemplo n.º 2
0
// Load a record onto the record player
void Crecord_playerApp::load_record(int a_index)
{

  // Verify valid input
  if (a_index < 0 || a_index >= NUM_RECORDS) return;

  if (stream) { BASS_ChannelStop(stream); Sleep(100); }
  int restart_haptics = 0;
  if (haptics_enabled) {
    restart_haptics = 1;
    toggle_haptics();
  }
  pos = 0;

  LoadAudioFile(g_audio_files[a_index]);
    
  stream=BASS_StreamCreate(info.freq,info.chans,0,&MyStreamWriter,0);
        
  // delete existing record
  if (m_recordMesh) { world->removeChild(m_recordMesh); delete m_recordMesh; }

  // create new record
  m_recordMesh = new cMesh(world);
  createTexCoords(m_recordMesh, 0.33);
  cTexture2D *record = new cTexture2D();

  bool result = record->loadFromFile(g_flag_files[a_index]);
  
  m_recordMesh->setTexture(record);
  m_recordMesh->useTexture(true, true);

  // Compute object size
  m_recordMesh->computeBoundaryBox(true);

  // Build a collision-detector for this object, so
  // the proxy will work nicely when haptics are enabled.
  m_recordMesh->createAABBCollisionDetector(true, true);

  // set size of frame
  m_recordMesh->setFrameSize(0.3, 1.0, true);

  // update global position
  m_recordMesh->computeGlobalPositions();

  // add object to world and translate
  world->addChild(m_recordMesh);
  m_recordMesh->translate(-0.1, 0, -0.21);

  // set stiffness
  double stiffness = (double)35;
  if (m_recordMesh)
    m_recordMesh->setStiffness(stiffness, true);

  // set static and dynamic friction
  double staticFriction = (double)100 / 100.0;
  double dynamicFriction = (double)100 / 100.0;
  if (m_recordMesh)
    m_recordMesh->setFriction(staticFriction, dynamicFriction, true);

  m_rotVel = 0.0;
  if (restart_haptics) toggle_haptics();
}