Example #1
0
	def prepare(self):

		"""See item."""

		base_response_item.prepare(self)
		if safe_decode(self.var.sample).strip() == u'':
			raise osexception(
				u'No sample has been specified in sampler "%s"' % self.name)
		sample = self.experiment.pool[self.var.sample]
		try:
			self.sampler = openexp_sampler(self.experiment, sample)
		except Exception as e:
			raise osexception(u'Failed to load sample: %s' % sample,
				exception=e)
		pan = self.var.pan
		if pan == -20:
			pan = u'left'
		elif pan == 20:
			pan = u'right'
		self.sampler.pan = pan
		self.sampler.volume = self.var.volume
		self.sampler.pitch = self.var.pitch
		self.sampler.fade_in = self.var.fade_in
		self.sampler.duration = self.var.stop_after
		self.sampler.block = self.var.duration == u'sound'
Example #2
0
	def prepare(self):

		"""See item."""

		base_response_item.prepare(self)
		# Create a canvas.
		self.canvas = canvas(self.experiment,
			background_color=self.var.background, color=self.var.foreground,
			penwidth=self.var.penwidth)
		# Set the coordinates.
		self._x = self.var.x
		self._y = self.var.y
		if self.var.uniform_coordinates != u'yes':
			self._x += self.canvas.width/2
			self._y += self.canvas.height/2
		# For backwards compatibility, we support a few special fixdot styles
		if self.var.style == u'filled':
			self.canvas.ellipse(self._x - 10, self._y - 10, 20, 20, fill=True)
		elif self.var.style == u'filled-small':
			self.canvas.ellipse(self._x - 5, self._y - 5, 10, 10, fill=True)
		elif self.var.style == u'empty':
			self.canvas.ellipse(self._x - 10, self._y - 10, 20, 20, fill=False)
		elif self.var.style == u'empty-small':
			self.canvas.ellipse(self._x - 5, self._y - 5, 10, 10, fill=False)
		elif self.var.style == u'cross':
			self.canvas.line(self._x - 10, self._y, self._x + 10, self._y)
			self.canvas.line(self._x, self._y - 10, self._x, self._y + 10)
		elif self.var.style == u'cross-small':
			self.canvas.line(self._x - 5, self._y, self._x + 5, self._y)
			self.canvas.line(self._x, self._y - 5, self._x, self._y + 5)
		# But the new way is to use the style keyword
		else:
			self.canvas.fixdot(self._x, self._y, style=self.var.style)
Example #3
0
	def prepare(self):

		"""See item."""

		base_response_item.prepare(self)
		self.canvas = canvas(self.experiment, color=self.var.foreground,
			background_color=self.var.background, auto_prepare=False)
		for element in self.elements:
			if element.is_shown():
				element.draw()
		self.canvas.prepare()
Example #4
0
	def prepare(self):

		"""Prepares for playback."""

		base_response_item.prepare(self)
		try:
			self.sampler = openexp_synth(self.experiment, osc=self.var.osc,
				freq=self.var.freq, length=self.var.length,
				attack=self.var.attack, decay=self.var.decay)
		except Exception as e:
			raise osexception(u'Failed to generate sound', exception=e)
		pan = self.var.pan
		if pan == -20:
			pan = u'left'
		elif pan == 20:
			pan = u'right'
		self.sampler.pan = pan
		self.sampler.volume = self.var.volume
		self.sampler.block = self.var.duration == u'sound'
Example #5
0
	def prepare(self):

		"""See item."""

		base_response_item.prepare(self)
		self._flush = self.var.flush == u'yes'