2012.03.31 include_once('../include/ensemble_echonest_api.php'); // debugging $outpath = '/home/fbarrett/data/logs/echonest_ensemble/js_meer_v2_ENplaylist_ajax.php'; $oh = fopen($outpath,'a+'); fwrite($oh,"\n----------------------\nDate:" . date('MdYHis') . "\n"); fwrite($oh,"subid: {$_SESSION['subject_id']}, session: {$_SESSION['session_id']}\n"); // set parameters to store stim info in database $pref_qid = 1101; $pref_formid = 464; // set params to construct this playlist $_SESSION['stim_root'] = 'https://atonal.ucdavis.edu/ensemble/stimuli/'; $_SESSION['en_params'] = array(); $_SESSION['en_params']['api_key'] = 'QVKVLGQZD44CKT8CX'; $_SESSION['en_params']['playlist_type'] = 'static'; $_SESSION['en_params']['playlist_params'] = array(); $_SESSION['en_params']['playlist_params']['api_key'] = $_SESSION['en_params']['api_key']; $_SESSION['en_params']['playlist_params']['format'] = 'json'; $_SESSION['en_params']['playlist_params']['type'] = 'artist-description'; $_SESSION['en_params']['playlist_params']['limit'] = 'true'; $_SESSION['en_params']['playlist_params']['bucket']['id']='CAESQRM1367E86DB88'; $_SESSION['en_params']['playlist_params']['bucket']['tracks'] = ''; //$_SESSION['en_params']['playlist_params']['variety'] = 1; $_SESSION['en_params']['playlist_params']['results'] = 4; //$_SESSION['en_params']['playlist_params']['description'] = array(); // if no en_playlist is set, retrieve one! if (!isset($_SESSION['en_stimids'])) { $stimids = array(); $prefout = array(); $prefary = array(0,1); $modeary = array(0,1); // iterate over preference and mode, get sets of stimuli foreach ($prefary as $pref) { $_SESSION['en_params']['preferred'] = $pref; $_SESSION['en_params']['playlist_params']['style'] = get_stomp_weighted_genres($_SESSION['en_params']['preferred']); foreach ($modeary as $mode) { $_SESSION['en_params']['playlist_params']['mode'] = $mode; for ($tempo=0;$tempo < 2;$tempo++) { switch ($tempo) { case 0: unset($_SESSION['en_params']['playlist_params']['min_tempo']); $_SESSION['en_params']['playlist_params']['max_tempo'] = 120; case 1: unset($_SESSION['en_params']['playlist_params']['max_tempo']); $_SESSION['en_params']['playlist_params']['min_tempo'] = 120; } // get an EchoNest playlist $pltype = $_SESSION['en_params']['playlist_type']; $endata = get_echonest_data('playlist/'.$pltype,$_SESSION['en_params']['playlist_params']); $playlist = $endata->{'songs'}; foreach ($playlist as $stim) { array_push($stimids,$stim->{'foreign_ids'}[0]->{'foreign_id'}); array_push($prefout,$pref); } // foreach($playlist as $stim fwrite($oh,"pref $pref, mode $mode, tempo $tempo, " . count($playlist) . " items\n"); } // for ($tempo=0;$tempo < 2; $tempo++ } // foreach ($modeary as $mode } // foreach ($prefary as $pref // randomize stim presentation $stimorder = array(); for ($i=0;$i