- Timestamp:
- 03/28/08 11:54:44 (4 years ago)
- Location:
- trunk
- Files:
-
- 17 modified
-
fm_gui/src/base.c (modified) (1 diff)
-
fm_server/src/fm_buffer.c (modified) (2 diffs)
-
fm_server/src/fm_buffer.h (modified) (1 diff)
-
fm_server/src/fm_djmixer.c (modified) (5 diffs)
-
fm_server/src/fm_effect_rubber/fm_effect_rubber.c (modified) (1 diff)
-
fm_server/src/fm_effect_rubber/fm_rubber_wrapper.cpp (modified) (1 diff)
-
fm_server/src/fm_element.c (modified) (3 diffs)
-
fm_server/src/fm_element.h (modified) (4 diffs)
-
fm_server/src/fm_input_cdj.c (modified) (6 diffs)
-
fm_server/src/fm_input_cdj.h (modified) (1 diff)
-
fm_server/src/fm_input_gst/fm_input_gst.c (modified) (2 diffs)
-
fm_server/src/fm_mixer.c (modified) (1 diff)
-
fm_server/src/fm_song_db/fm_song_db.c (modified) (4 diffs)
-
fm_server/src/fm_song_db/fm_xml_db.c (modified) (1 diff)
-
fm_server/src/fm_song_db/fm_xml_db.h (modified) (1 diff)
-
fm_server/src/fm_sync.c (modified) (5 diffs)
-
fm_server/src/fm_sync.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/fm_gui/src/base.c
r228 r246 40 40 rgc_remote_object_new_async (fm_cdj_created_cb, data, 41 41 "FmInputCDJ", "input", NULL); 42 rgc_remote_object_new_async (fm_cdj_created_cb, data,43 "FmInputCDJ", "input", NULL); 42 /* rgc_remote_object_new_async (fm_cdj_created_cb, data, 43 "FmInputCDJ", "input", NULL);*/ 44 44 /* rgc_remote_object_new_async (fm_beatgen_created_cb, data, 45 45 "FmInputBeatgen", "input", NULL);*/ -
trunk/fm_server/src/fm_buffer.c
r245 r246 60 60 61 61 buffer->timestamp_ns = 0; 62 buffer->timestamp_samples = 0;62 // buffer->timestamp_samples = 0; 63 63 buffer->duration = 0; 64 64 … … 121 121 buffer->silence = FALSE; 122 122 buffer->timestamp_ns = -1; 123 buffer->timestamp_samples = -1;123 // buffer->timestamp_samples = -1; 124 124 buffer->duration = 0; 125 125 } -
trunk/fm_server/src/fm_buffer.h
r245 r246 51 51 52 52 gint64 timestamp_ns; // real timestamp from start of the song 53 gint64 timestamp_samples;53 // gint64 timestamp_samples; 54 54 guint64 duration; // real duration of AUDIO (not silence) in the buffer 55 55 }; -
trunk/fm_server/src/fm_djmixer.c
r196 r246 158 158 djm->master_level = fm_level_meter_new (); 159 159 160 g_object_set_data (G_OBJECT (djm->mixer), "name", g_strdup_printf ("mixer")); 161 g_object_set_data (G_OBJECT (djm->master_gain), "name", g_strdup_printf ("master_gain")); 162 g_object_set_data (G_OBJECT (djm->master_level), "name", g_strdup_printf ("master_level")); 163 160 164 fm_element_connect_src (FM_ELEMENT (djm->master_level), FM_ELEMENT (djm->master_gain)); 161 165 fm_element_connect_src (FM_ELEMENT (djm->master_gain), FM_ELEMENT (djm->mixer)); … … 224 228 FmDJMixer *djm = FM_DJMIXER (element); 225 229 230 static gint serial = 0; 226 231 FmDJMixerChannel *chan = g_new0 (FmDJMixerChannel, 1); 227 232 chan->owner = djm; … … 232 237 chan->fader = fm_effect_gain_new (); 233 238 239 g_object_set_data (G_OBJECT (chan->fader), "name", g_strdup_printf ("chan_fader%d", serial)); 240 g_object_set_data (G_OBJECT (chan->meter), "name", g_strdup_printf ("chan_meter%d", serial)); 241 g_object_set_data (G_OBJECT (chan->pan), "name", g_strdup_printf ("chan_pan%d", serial)); 242 g_object_set_data (G_OBJECT (chan->gain), "name", g_strdup_printf ("chan_gain%d", serial)); 243 serial++; 244 234 245 fm_pipeline_add_element (element->pipeline, FM_ELEMENT (chan->fader)); 235 246 fm_pipeline_add_element (element->pipeline, FM_ELEMENT (chan->meter)); … … 308 319 FmDJMixer *djm = FM_DJMIXER (element); 309 320 310 fm_element_get_buffer (FM_ELEMENT (djm->master_level), buffer, element->sync_ ref);321 fm_element_get_buffer (FM_ELEMENT (djm->master_level), buffer, element->sync_data); 311 322 } 312 323 … … 321 332 322 333 FmElement *mixer_el = FM_ELEMENT (djm->mixer); 323 mixer_el->sync_ ref= sync;324 } 334 mixer_el->sync_data = sync; 335 } -
trunk/fm_server/src/fm_effect_rubber/fm_effect_rubber.c
r245 r246 270 270 if ((rubber->last_timestamp == start_timestamp) && (start_timestamp == -1)) 271 271 return; 272 g_print ("%s pos %ld\n", fm_element_get_name (element), buffer->timestamp_ns);272 // g_print ("%s pos %ld\n", fm_element_get_name (element), buffer->timestamp_ns); 273 273 rubber->last_timestamp = buffer->timestamp_ns; 274 274 } -
trunk/fm_server/src/fm_effect_rubber/fm_rubber_wrapper.cpp
r238 r246 11 11 *fm_rubber_wrapper_new (void) 12 12 { 13 g_print ("RRRRRRRRRUUUUUUUBBBBBBBEEEEEEERRRRRR\n");14 15 13 FmRubberWrapper *wrap = g_new0 (FmRubberWrapper, 1); 16 14 RubberBandStretcher *ts = new RubberBandStretcher (44100, 2, RubberBandStretcher::OptionProcessRealTime, 1.0, 1.0); -
trunk/fm_server/src/fm_element.c
r245 r246 159 159 160 160 element->pipeline = NULL; 161 element->sync_ ref= NULL;161 element->sync_data = NULL; 162 162 element->sync_master = FALSE; 163 element->sync_slave = FALSE; 164 element->sync_ref = FALSE; 163 165 } 164 166 … … 445 447 g_print ("fm_element_become_sync_ref on %p!\n", element); 446 448 447 element->sync_ref = g_new0 (FmSync, 1); 449 element->sync_data = g_new0 (FmSync, 1); 450 element->sync_ref = TRUE; 448 451 } 449 452 … … 457 460 g_return_if_fail (klass->become_sync_master); 458 461 459 g_print ("new sync master is %p %s\n", peer_sync_master, peer_sync_master->name);462 g_print ("new sync master is %p %s\n", peer_sync_master, fm_element_get_name (peer_sync_master)); 460 463 461 464 reference->peer_sync_master = peer_sync_master; 462 465 peer_sync_master->sync_master = TRUE; 463 (*klass->become_sync_master) (peer_sync_master, reference->sync_ ref);466 (*klass->become_sync_master) (peer_sync_master, reference->sync_data); 464 467 } 465 468 -
trunk/fm_server/src/fm_element.h
r245 r246 60 60 typedef struct _FmSync FmSync; 61 61 struct _FmSync { 62 gboolean in_use;62 gboolean valid; 63 63 64 64 FmElement *master; … … 74 74 gint bar; 75 75 gint beat; 76 gfloat beat_offset_ns; 76 gint beat_offset_ns; 77 gfloat beat_offset_float; 77 78 78 79 gdouble bpm_new; … … 98 99 gpointer pipeline; 99 100 100 FmSync *sync_ref; 101 gboolean sync_master; 101 FmSync *sync_data; // owned by sync_ref 102 103 gboolean sync_master; // the element leads the sync 104 gboolean sync_slave; // the element follows the sync 105 gboolean sync_ref; // the mixer element used as a base for sync 102 106 }; 103 107 … … 111 115 gboolean (*activate) (FmElement *element); 112 116 gboolean (*deactivate) (FmElement *element); 117 void (*become_sync_master) (FmElement *element, 118 FmSync *sync); 119 void (*become_sync_slave) (FmElement *element, 120 FmSync *sync); 113 121 void (*become_sync_ref) (FmElement *element, 114 FmSync *sync);115 void (*become_sync_master) (FmElement *element,116 122 FmSync *sync); 117 123 void (*get_buffer) (FmElement *element, -
trunk/fm_server/src/fm_input_cdj.c
r245 r246 289 289 { 290 290 g_print ("FmInputCDJ has become sync master!\n"); 291 292 sync->in_use = TRUE;293 294 sync->bpm = 120.0;295 sync->beat_per_bar = 4;296 291 } 297 292 … … 316 311 317 312 313 FmBeatSection *beat_sect = fm_sync_get_beatsection (input_cdj->beat_info, buffer->timestamp_ns); 314 318 315 319 316 if (fm_element_is_sync_master (element)) { 320 if (FM_BUFFER_DISCONT (buffer)) { 317 /*if (beat_sect) 318 sync->valid = TRUE; 319 else { 320 sync->valid = FALSE; 321 return; 322 }*/ 323 324 fm_sync_update_pos (sync, beat_sect, buffer->timestamp_ns); 325 326 /*if (FM_BUFFER_DISCONT (buffer)) { 321 327 g_print ("**************************************************************************************************\n"); 322 328 g_print ("DISCONT buffer! new pos %llu\n", (long long unsigned int) buffer->timestamp_ns); … … 326 332 fm_sync_master_played_ns (sync, FM_BUFFER_DURATION (buffer)); 327 333 fm_sync_update_cycle (sync); 328 } 329 330 if ( FM_BUFFER_DURATION (buffer) >0)334 }*/ 335 336 if (buffer->timestamp_ns >= 0) 331 337 fm_sync_show_pos (sync); 332 338 } … … 387 393 fm_input_cdj_update_bpm (FmInputCDJ *input_cdj) 388 394 { 389 gdouble bpm;395 /*gdouble bpm; 390 396 if (input_cdj->beat_section) 391 397 bpm = input_cdj->beat_section->bpm / fm_effect_rubber_get_time_ratio (input_cdj->rate); … … 394 400 GValue *val = g_value_init_double (bpm); 395 401 rgc_signal_emit (input_cdj, "bpm_changed", val, NULL); 396 g_value_destroy (val); 402 g_value_destroy (val);*/ 397 403 } 398 404 … … 407 413 g_value_destroy(fn); 408 414 409 FmBeatInfo *beat_info = fm_song_db_get_beatinfo (global_song_db, filename);410 411 if (! beat_info) {415 input_cdj->beat_info = fm_song_db_get_beatinfo (global_song_db, filename); 416 417 if (!input_cdj->beat_info) { 412 418 g_print ("Song \"%s\" isn't in the song database\n", filename); 413 input_cdj->beat_section = NULL;414 419 return; 415 420 } 416 421 417 if (! beat_info->beatsections) {422 if (!input_cdj->beat_info->beatsections) { 418 423 g_print ("Song \"%s\" doesn't have beat information\n", filename); 419 input_cdj->beat_section = NULL;420 424 return; 421 425 } 422 426 423 FmBeatSection *beat_section = beat_info->beatsections->data; 427 fm_sync_dump_beatsections (input_cdj->beat_info); 428 /*FmBeatSection *beat_section = beat_info->beatsections->data; 424 429 input_cdj->beat_section = beat_section; 425 430 g_print ("Beat info: start %lld, end %lld, bpm %lf\n", (long long int) beat_section->start, (long long int) beat_section->end, beat_section->bpm); 426 fm_input_cdj_update_bpm (input_cdj); 431 fm_input_cdj_update_bpm (input_cdj);*/ 427 432 } 428 433 -
trunk/fm_server/src/fm_input_cdj.h
r238 r246 38 38 FmEffectRubber *rate; 39 39 40 FmBeat Section *beat_section;40 FmBeatInfo *beat_info; 41 41 }; 42 42 -
trunk/fm_server/src/fm_input_gst/fm_input_gst.c
r245 r246 617 617 // g_print ("FILL\n"); 618 618 buffer->timestamp_ns = -1; 619 buffer->timestamp_samples = -1;619 // buffer->timestamp_samples = -1; 620 620 return; 621 621 } … … 650 650 chk->samples_read += useful_read_samples; 651 651 652 buffer->timestamp_samples = current_pos_samples_old;653 buffer->timestamp_ns = samples_to_ns (common, buffer->timestamp_samples);652 // buffer->timestamp_samples = current_pos_samples_old; 653 buffer->timestamp_ns = samples_to_ns (common, current_pos_samples_old); 654 654 buffer->used_samples = buffer->requested_samples; 655 655 buffer->duration = samples_to_ns (common, useful_read_samples); -
trunk/fm_server/src/fm_mixer.c
r196 r246 243 243 FM_BUFFER_REQUESTED (mixer->buffers[i]) = FM_BUFFER_REQUESTED (buffer); 244 244 245 g_print ("Getting data from master port\n"); 245 246 fm_element_get_buffer (element->peer_sync_master, mixer->buffers[i++], sync); 246 247 } -
trunk/fm_server/src/fm_song_db/fm_song_db.c
r199 r246 90 90 fm_song_db_init (FmSongDB *song_db) 91 91 { 92 #define FILENAME "/ tmp/song_db.xml"92 #define FILENAME "/home/ath/Projects/FreeMix/song_db.xml" 93 93 94 94 fm_xml_db_init (); … … 96 96 song_db->xml_db = fm_xml_db_new (FILENAME); 97 97 98 g_print ("alright! %p\n", song_db->xml_db); 99 100 //fm_xml_db_dump (song_db->xml_db); 98 g_print ("Song database loaded, %p\n", song_db->xml_db); 101 99 102 100 /*gint res; … … 126 124 127 125 gint count = fm_xml_db_get_beatsection_count (song_db->xml_db, filename); 126 //fm_xml_db_dump (song_db->xml_db, filename); 128 127 129 128 if (count == -1) … … 131 130 132 131 info = g_new0 (FmBeatInfo, 1); 132 info->current = NULL; 133 133 gint i; 134 134 -
trunk/fm_server/src/fm_song_db/fm_xml_db.c
r199 r246 109 109 110 110 void 111 fm_xml_db_dump (FmXmlDb *db) 111 fm_xml_db_dump (FmXmlDb *db, 112 const gchar *song_filename) 112 113 { 113 114 xmlNode *nod = fm_xml_db_search_song (db, "lady.mp3"); 114 115 115 116 g_print ("%p\n", nod); 116 //print_element_names(db->root_element);117 print_element_names(db->root_element); 117 118 } 118 119 -
trunk/fm_server/src/fm_song_db/fm_xml_db.h
r199 r246 39 39 40 40 void 41 fm_xml_db_dump (FmXmlDb *db); 41 fm_xml_db_dump (FmXmlDb *db, 42 const gchar *song_filename); 42 43 43 44 gint -
trunk/fm_server/src/fm_sync.c
r195 r246 33 33 34 34 35 void35 /*void 36 36 fm_sync_update_cycle (FmSync *sync) 37 37 { … … 46 46 } 47 47 48 // guint sample_rate = /* fm_pipeline_get_sample_rate() */44100;48 // guint sample_rate = 44100; 49 49 // sync->ns_per_sample = (1.0 / sample_rate) * NS_PER_SEC; 50 50 sync->ns_per_beat = NS_PER_SEC / (sync->bpm / 60.0); … … 65 65 sync->beat = 0; 66 66 } 67 } 67 }*/ 68 68 69 69 70 void70 /*void 71 71 fm_sync_master_played_ns (FmSync *sync, 72 72 guint ns) 73 73 { 74 74 sync->played_ns_new = ns; 75 } 75 }*/ 76 76 77 77 78 void78 /*void 79 79 fm_sync_master_set_bpm (FmSync *sync, 80 80 gdouble bpm) 81 81 { 82 82 sync->bpm_new = bpm; 83 } 83 }*/ 84 84 85 void85 /*void 86 86 fm_sync_set (FmSync *sync, 87 87 guint64 offset, … … 94 94 sync->beat_offset_ns = realstamp - (beats * sync->ns_per_beat); 95 95 96 } 96 }*/ 97 97 98 gdouble98 /*gdouble 99 99 fm_sync_ns_to_next_beat (FmSync *sync) 100 100 { 101 101 return (sync->ns_per_beat - sync->beat_offset_ns); 102 } 102 }*/ 103 103 104 104 105 gint105 /*gint 106 106 fm_sync_next_beat_is (FmSync *sync) 107 107 { … … 112 112 113 113 return next_beat; 114 } 114 }*/ 115 115 116 116 void 117 117 fm_sync_show_pos (FmSync *sync) 118 118 { 119 g_print ("bpm: %lf pos: bar %d beat %d beat_offset_ns %f\n", sync->bpm, sync->bar, sync->beat, sync->beat_offset_ns); 119 if (!sync->valid) 120 return; 121 122 g_print ("bpm: %.3lf pos: bar %d beat %d beat_offset %.5f\n", sync->bpm, sync->bar, sync->beat, sync->beat_offset_float); 120 123 } 124 125 void 126 fm_sync_dump_beatsections (FmBeatInfo *info) 127 { 128 g_return_if_fail (info); 129 130 GList *sections = info->beatsections; 131 while (sections) { 132 FmBeatSection *sect = sections->data; 133 134 g_print ("Beat info: start %lld, end %lld, bpm %lf\n", 135 (long long int) sect->start, (long long int) sect->end, sect->bpm); 136 137 sections = sections->next; 138 } 139 140 } 141 142 FmBeatSection * 143 fm_sync_get_beatsection (FmBeatInfo *info, 144 guint64 ns) 145 { 146 if (!info) 147 return NULL; 148 149 g_return_val_if_fail (info->beatsections, NULL); 150 151 if ((info->current) && 152 (info->current->start <= ns) && (info->current->start <= ns)) 153 return info->current; 154 155 info->current = NULL; 156 157 GList *sections = info->beatsections; 158 while (sections) { 159 FmBeatSection *sect = sections->data; 160 161 if ((sect->start <= ns) && (sect->start <= ns)) 162 info->current = sect; 163 164 sections = sections->next; 165 } 166 167 return info->current; 168 } 169 170 171 void 172 fm_sync_update_pos (FmSync *sync, 173 FmBeatSection *sect, 174 gint64 pos) 175 { 176 g_return_if_fail (sync); 177 178 if ((!sect) || (pos < 0)) { 179 sync->valid = FALSE; 180 return; 181 } 182 183 sync->valid = TRUE; 184 185 sync->beat_per_bar = 4; 186 sync->bpm = sect->bpm; 187 188 sync->ns_per_beat = NS_PER_SEC / (sync->bpm / 60.0); 189 190 guint beat = pos / sync->ns_per_beat; 191 192 sync->bar = beat / sync->beat_per_bar; 193 sync->beat = beat - (sync->bar * sync->beat_per_bar); 194 sync->beat_offset_ns = pos - (beat * sync->ns_per_beat); 195 sync->beat_offset_float = sync->beat_offset_ns / sync->ns_per_beat; 196 } -
trunk/fm_server/src/fm_sync.h
r195 r246 35 35 struct _FmBeatInfo { 36 36 GList *beatsections; 37 38 FmBeatSection *current; 37 39 }; 38 40 … … 55 57 56 58 /* The sync reference has to call this after calling fm_get_buffer() on its peer_sync_master port */ 57 void58 fm_sync_update_cycle (FmSync *sync); 59 /*void 60 fm_sync_update_cycle (FmSync *sync);*/ 59 61 60 62 /* Callable from get_buffer, takes effect from next cycle */ 61 void63 /*void 62 64 fm_sync_master_played_ns (FmSync *sync, 63 guint samples); 65 guint samples);*/ 64 66 65 67 /* Callable outside of get_buffer, take effect from next cycle */ 66 void68 /*void 67 69 fm_sync_master_set_bpm (FmSync *sync, 68 gdouble bpm); 70 gdouble bpm);*/ 69 71 70 void72 /*void 71 73 fm_sync_set (FmSync *sync, 72 74 guint64 offset, 73 guint64 timestamp); 75 guint64 timestamp);*/ 74 76 75 77 /* Callable from get_buffer */ 76 gdouble77 fm_sync_ns_to_next_beat (FmSync *sync); 78 /*gdouble 79 fm_sync_ns_to_next_beat (FmSync *sync);*/ 78 80 79 gint80 fm_sync_next_beat_is (FmSync *sync); 81 /*gint 82 fm_sync_next_beat_is (FmSync *sync);*/ 81 83 82 84 void 83 85 fm_sync_show_pos (FmSync *sync); 86 87 void 88 fm_sync_dump_beatsections (FmBeatInfo *info); 89 90 FmBeatSection * 91 fm_sync_get_beatsection (FmBeatInfo *info, 92 guint64 ns); 93 94 void 95 fm_sync_update_pos (FmSync *sync, 96 FmBeatSection *sect, 97 gint64 pos);
