int 
main(int argc, char *argv[])
{
  if (argc != PARAMS+1)
    usage(argv[0]);

  SimilarityStrategy similarity;
  SQLiteDatabase database(argv[1]);
  OptionList options("",1,3000,0,0,0,0,25);
  Generator generator(database, similarity);

  if(generator.initialization() == 0)
  {
    cout << "Erreur d'initialisation" << endl;
    exit(EXIT_FAILURE);
  }
  Playlist playlist = generator.generate(options);
  auto first = playlist.begin();
  int i = 1;
  for(auto it = playlist.begin(); it != playlist.end(); ++it)
    cout << "Similarité entre le morceau 1 et " << i++ << " : " << similarity.compute(*first,*it) << endl;


  return EXIT_SUCCESS;
}
Example #2
0
Playlist Generator::regenerate(OptionList optionList, Playlist playlist)
{
  //Recupération d'une pool de morceaux
  TrackPool pool = db.select(optionList,optionList.getSize()*POOL_SIZE_FACTOR);
  selectionFeedback.notifyAll(pool.size(), pool);
  if(pool.size() == 0)
    return playlist;
  //On remplit la pool avec les morceaux de la playlist précédente
  for(auto it = playlist.begin(); it != playlist.end(); ++it)
    pool.insert(*it);
  Playlist newPlaylist;
  //On lance la génération
  generationLoop(&newPlaylist, pool, optionList.getSize());
  return newPlaylist;
}
int 
main(int argc, char *argv[])
{
  if (argc != PARAMS+1)
    usage(argv[0]);
  int k = atoi(argv[2]);
  SimilarityStrategy similarity;
  SQLiteDatabase database(argv[1]);
  OptionList options("",1,3000,0,0,0,0,25);
  Generator generator(database, similarity);

  if(generator.initialization() == 0)
  {
    cout << "Erreur d'initialisation" << endl;
    exit(EXIT_FAILURE);
  }
  Playlist playlist = generator.generate(options);
  int i = 1;
  auto it = playlist.begin();
  for(int n = 0; n < k-1; n++)
  {
    ++i; ++it;
  }
  while(it != playlist.end())
  {
    ++it; ++i;
    auto next = it; ++next;
    auto previous = it;
    for(int n = 0; n < k; n++)
    {
      --previous;
    }
    if(next != playlist.end() && it != playlist.end())
    {
      cout << "Similarité entre le le morceau " << i <<  " et le morceau " << i+1 << " : " << similarity.compute(*it,*next) << endl;
      cout << "Similarité entre le le morceau " << i-k <<  " et le morceau " << i+1 << " : " << similarity.compute(*previous,*next) << endl;
      cout << "Différence " << i << "-" << i+1 << " | " << i-k << "-" << i+1 << " : "<< similarity.compute(*it,*next)-similarity.compute(*previous,*next) << endl;
    }
  }

  return EXIT_SUCCESS;
}
void print_playlist(gPlay* player)
{
  int ctr = 1;
  
  Playlist playlist = player->getPlaylist();
  Playlist::const_iterator playlistPosition = player->playlistPosition();
  
  g_print("============= PLAYLIST =============\n");
  for ( Playlist::const_iterator pos = playlist.begin(); pos != playlist.end(); ++pos){
    const Track* t = *pos;
    if (t->title.length() == 0){
      gchar* filename = g_filename_from_uri(t->uri.c_str(), NULL, NULL);
      gchar* basename = g_path_get_basename(filename);
      
      if ( g_strcmp0((*pos)->uri.c_str(), (*playlistPosition)->uri.c_str()) == 0 ){
	g_print("\033[31m%02d - %s by %s\033[39m\n", ctr, basename, t->artist.c_str());
      }
      
      else
	g_print("%02d - %s by %s\n", ctr, basename, t->artist.c_str());
      
      g_free(basename);
      g_free(filename);
      
    } 
    else{
      if ( g_strcmp0((*pos)->uri.c_str(), (*playlistPosition)->uri.c_str()) == 0){
	g_print("\033[31m%02d - %s by %s\n\033[39m", ctr, t->title.c_str(), t->artist.c_str());
      }
      else
	g_print("%02d - %s by %s\n", ctr, t->title.c_str(), t->artist.c_str());
    }
    ++ctr;
  }
  g_print("====================================\n");
}