1
0
mirror of https://github.com/psychopy/psychojs.git synced 2025-05-10 10:40:54 +00:00
This commit is contained in:
Alain Pitiot 2020-05-12 18:31:11 +02:00
parent 0ca9e118a4
commit 1cf40c4d8a
6 changed files with 39 additions and 11 deletions

View File

@ -135,7 +135,7 @@ export class GUI
// only create an input if the key is not in the URL:
let inUrl = false;
const cleanedDictKey = key.trim().toLowerCase();
infoFromUrl.forEach( (urlKey, urlValue) =>
infoFromUrl.forEach( (urlValue, urlKey) =>
{
const cleanedUrlKey = urlKey.trim().toLowerCase();
if (cleanedUrlKey === cleanedDictKey) {

View File

@ -215,7 +215,8 @@ export class TrialHandler extends PsychObject {
ran: this.ran,
finished: this.finished,
getCurrentTrial: () => this.getTrial(currentIndex)
getCurrentTrial: () => this.getTrial(currentIndex),
getTrial: (index = 0) => this.getTrial(index)
};
return snapshot;

View File

@ -21,6 +21,9 @@ import { TrackPlayer } from './TrackPlayer';
* <li> If value is a number then a tone will be generated at that frequency in Hz.</li>
* <li> It value is a string, it must either be a note in the PsychoPy format (e.g 'A', 'Bfl', 'B', 'C', 'Csh'), in which case an octave must also be given, or the name of the resource track.</li>
* </ul>
*
* <p> Note: the PsychoPy hamming parameter has not been implemented yet. It might be rather tricky to do so using
* Tone.js</p>
*
* @example
* [...]
@ -45,7 +48,6 @@ import { TrackPlayer } from './TrackPlayer';
* @param {boolean} [options.stereo= true] whether or not to play the sound or track in stereo
* @param {number} [options.volume= 1.0] - volume of the sound (must be between 0 and 1.0)
* @param {number} [options.loops= 0] - how many times to repeat the track or tone after it has played once. If loops == -1, the track or tone will repeat indefinitely until stopped.
* @param {boolean} [options.hamming= true] whether or not to apodize the sound (i.e., the onset and offset smoothly ramped up from down to zero). This only affects tones.
* @param {boolean} [options.autoLog= true] whether or not to log
*/
export class Sound extends PsychObject {
@ -60,7 +62,7 @@ export class Sound extends PsychObject {
stereo = true,
volume = 1.0,
loops = 0,
hamming = true,
//hamming = true,
autoLog = true
} = {}) {
super(win._psychoJS, name);
@ -68,7 +70,7 @@ export class Sound extends PsychObject {
// the SoundPlayer, e.g. TonePlayer:
this._player = undefined;
this._addAttributes(Sound, win, value, octave, secs, startTime, stopTime, stereo, volume, loops, hamming, autoLog);
this._addAttributes(Sound, win, value, octave, secs, startTime, stopTime, stereo, volume, loops, /*hamming,*/ autoLog);
// identify an appropriate player:
this._getPlayer();

View File

@ -178,14 +178,15 @@ export class CountdownTimer extends Clock {
* @name module:util.CountdownTimer#reset
* @function
* @public
* @param {number} [newTime] - if newTime is undefined, the coundown time is reset to zero, otherwise we set it to newTime
* @param {number} [newTime] - if newTime is undefined, the countdown time is reset to zero, otherwise we set it
* to newTime
*/
reset(newTime = undefined) {
if (typeof newTime == 'undefined') {
this._timeAtLastReset = MonotonicClock.getReferenceTime() + this._countdown_duration;
}
else {
this._countdown_duration = t;
this._countdown_duration = newTime;
this._timeAtLastReset = MonotonicClock.getReferenceTime() + newTime;
}
}

View File

@ -607,7 +607,7 @@ export function addInfoFromUrl(info)
// note: parameters starting with a double underscore are reserved for client/server communication,
// we do not add them to info
// for (const [key, value] of infoFromUrl)
infoFromUrl.forEach( (key, value) =>
infoFromUrl.forEach( (value, key) =>
{
if (key.indexOf('__') !== 0)
info[key] = value;
@ -743,4 +743,4 @@ export function offerDataForDownload(filename, data, type) {
elem.click();
document.body.removeChild(elem);
}
}
}

View File

@ -555,9 +555,17 @@ export class Slider extends util.mix(VisualStim).with(ColorMixin)
self._markerDragging = false;
this._marker.pointerdown = this._marker.mousedown = this._marker.touchstart = (event) => {
if (event.data.button === 0)
if (event.data.button === 0) {
self._markerDragging = true;
// set markerPos, but not rating:
const mouseLocalPos_px = event.data.getLocalPosition(self._pixi);
const rating = self._posToRating([mouseLocalPos_px.x, mouseLocalPos_px.y]);
self._markerPos = self._granularise(rating);
self._needMarkerUpdate = true;
}
event.stopPropagation();
};
@ -601,8 +609,24 @@ export class Slider extends util.mix(VisualStim).with(ColorMixin)
// (*) slider mouse events outside of marker
// note: this only works thanks to eventCaptureRectangle
this._pixi.pointerdown = this._pixi.mousedown = this._pixi.touchstart = (event) => {
if (event.data.button === 0) {
self._markerDragging = true;
// set markerPos, but not rating:
const mouseLocalPos_px = event.data.getLocalPosition(self._body);
const rating = self._posToRating([mouseLocalPos_px.x, mouseLocalPos_px.y]);
self._markerPos = self._granularise(rating);
// update the marker:
self._needMarkerUpdate = true;
self._updateMarker();
}
event.stopPropagation();
};
this._pixi.pointerup = this._pixi.mouseup = this._pixi.touchend = (event) => {
// this._body.pointerup = this._body.mouseup = this._body.touchend = event => { console.log(event);
const mouseLocalPos_px = event.data.getLocalPosition(self._body);
const rating = self._posToRating([mouseLocalPos_px.x, mouseLocalPos_px.y]);
self._recordRating(rating);