EVR.include("animation/ending/family/Member.js");
EVR.Animation.Ending.Family = function(ending)
{
   this.ending = ending;
   this.tombstone = ending.tombstone;
   this.container = ending.container;
   this.add_members();
}
EVR.Animation.Ending.Family.prototype.add_members = function()
{
   var attributes = FAMILY_ATTRIBUTES;
   var members = [];
   for (var ii = 0; ii < attributes.length; ii++)
   {
      members.push(
	 new EVR.Animation.Ending.Family.Member(this, attributes[ii]));
   }
   this.members = members;
}
EVR.Animation.Ending.Family.prototype.append = function()
{
   this.apply_to_members("append");
}
EVR.Animation.Ending.Family.prototype.apply_to_members = function(method)
{
   var member, members = this.members;
   var args = Array.prototype.slice.call(arguments);
   for (var ii = 0; ii < members.length; ii++)
   {
      member = members[ii];
      member[method].apply(member, args.slice(1));
   }
}
EVR.Animation.Ending.Family.prototype.play = function(name, delay)
{
   this.apply_to_members("play", name, delay);
}
EVR.Animation.Ending.Family.prototype.stop = function()
{
   this.apply_to_members("stop");
}
EVR.Animation.Ending.Family.prototype.reset = function()
{
   this.apply_to_members("reset");
}
EVR.Animation.Ending.Family.prototype.draw = function()
{
   this.apply_to_members("draw");
}
EVR.Animation.Ending.Family.prototype.remove = function()
{
   this.apply_to_members("remove");
}
EVR.Animation.Ending.Family.prototype.toString = function()
{
   return "[object EVR.Animation.Ending.Family]";
}
EVR.Animation.Ending.Family.Member = function(family, attributes)
{
   EVR.Animation.call(this, FAMILY_FRAME_RATE);
   this.attributes = attributes;
   this.step = FAMILY_STEP;
   this.jump_step = FAMILY_JUMP_STEP;
   this.shifted = false;
   this.avatar = new EVR.Emoticon(family.container, family.tombstone);
   this.set_attributes();
   this.remove();
}
EVR.Animation.Ending.Family.Member.prototype = new EVR.Animation;
EVR.Animation.Ending.Family.Member.prototype.set_attributes = function()
{
   var attributes = this.attributes;
   var size = attributes[0];
   var offset = attributes[1];
   var color = attributes[2];
   var avatar = this.avatar;
   avatar.set_proportions(1, size);
   avatar.place(offset, 0);
   avatar.set_color(color);
}
EVR.Animation.Ending.Family.Member.prototype.remove = function()
{
   this.avatar.remove();
}
EVR.Animation.Ending.Family.Member.prototype.append = function()
{
   this.avatar.append();
}
EVR.Animation.Ending.Family.Member.prototype.sequence = function()
{
   var avatar = this.avatar;
   if (this.shifted)
   {
      avatar.move(-this.step);
      this.shifted = false;
   }
   if (Math.random() < FAMILY_SHIFT_PROBABILITY)
   {
      avatar.move(this.step);
      this.shifted = true;
   }
}
EVR.Animation.Ending.Family.Member.prototype.jump = function()
{
   var avatar = this.avatar;
   var returned = false;
   if (this.jumped)
   {
      avatar.move(null, -this.jump_step);
      this.jumped = false;
      returned = true;
   }
   if (!returned && Math.random() < FAMILY_JUMP_PROBABILITY)
   {
      avatar.move(null, this.jump_step);
      this.jumped = true;
   }
}
EVR.Animation.Ending.Family.Member.prototype.reset = function()
{
   var avatar = this.avatar;
   if (this.jumped)
   {
      avatar.move(null, -this.jump_step);
      this.jumped = false;
   }
   if (this.shifted)
   {
      avatar.move(-this.step);
      this.shifted = false;
   }
}   
EVR.Animation.Ending.Family.Member.prototype.draw = function()
{
   this.avatar.draw();
}
EVR.Animation.Ending.Family.Member.prototype.toString = function()
{
   return "[object EVR.Animation.Ending.Family.Member]";
}
EVR.include("animation/ending/corpse/Soul.js");
EVR.Animation.Ending.Corpse = function(ending)
{
   EVR.Animation.call(this, CORPSE_FRAME_RATE);
   this.ending = ending;
   this.container = ending.container;
   this.add_children();
   this.set_attributes();
   this.place_offscreen();
}
EVR.Animation.Ending.Corpse.prototype = new EVR.Animation;
EVR.Animation.Ending.Corpse.prototype.add_children = function()
{
   this.soul = new EVR.Animation.Ending.Corpse.Soul(this);
   this.add_avatar();
}
EVR.Animation.Ending.Corpse.prototype.add_avatar = function()
{
   var ending = this.ending;
   var avatar = new EVR.Emoticon(ending.container, ending.tombstone, ALIGN_TOP);
//    avatar.ratio_type = RATIO_WIDTH;
   avatar.remove();
   this.avatar = avatar;
}
EVR.Animation.Ending.Corpse.prototype.set_attributes = function()
{
   var avatar = this.avatar;
   avatar.set_proportions(1, CORPSE_HEIGHT);
   avatar.set_z(CORPSE_Z_INDEX);
}
EVR.Animation.Ending.Corpse.prototype.reset = function()
{
   var avatar = this.avatar;
   avatar.set_proportions(1, CORPSE_HEIGHT);
   avatar.set_z(CORPSE_Z_INDEX);
   this.place_offscreen();
   this.soul.reset();
}
EVR.Animation.Ending.Corpse.prototype.place_offscreen = function()
{
   this.avatar.place(0, .1);
}
EVR.Animation.Ending.Corpse.prototype.append = function()
{
   this.avatar.append();
   this.soul.append();
}
EVR.Animation.Ending.Corpse.prototype.sequence = function()
{
   var avatar = this.avatar;
   avatar.move(null, CORPSE_STEP);
   var y = avatar.get_coordinates(true)[1] + avatar.get_dimensions(true)[1];
   if (y < 0)
   {
      this.stop();
      avatar.set_z(CORPSE_ZOOM_Z_INDEX);
      this.play("zoom", CORPSE_ZOOM_DELAY);
   }
}
EVR.Animation.Ending.Corpse.prototype.zoom = function()
{
   var avatar = this.avatar;
   avatar.grow(avatar.get_dimensions(true)[1] * CORPSE_ZOOM_RATE);
   var coordinates = avatar.get_coordinates(true);
   var size = avatar.get_dimensions(true);
   if (size[1] > .8 && !this.soul.playing)
   {
      this.soul.play();
   }
   if (size[1] > 1000)
   {
      this.stop();
   }
   var eye_offset = CORPSE_EYE_OFFSET;
   var offset = [size[0] * eye_offset[0], size[1] * eye_offset[1]];
   var eye_coordinates = 
      [coordinates[0] + offset[0], coordinates[1] + offset[1]];
   var endpoint = CORPSE_ZOOM_ENDPOINT;
   var step = CORPSE_ZOOM_STEP;
   var x = (endpoint[0] - eye_coordinates[0]) * step;
   var y = (endpoint[1] - eye_coordinates[1]) * step;
   avatar.move(x, y);
}
EVR.Animation.Ending.Corpse.prototype.draw = function()
{
   this.avatar.draw();
   this.soul.draw();
}
EVR.Animation.Ending.Corpse.prototype.remove = function()
{
   this.avatar.remove();
   this.soul.remove();
}
EVR.Animation.Ending.Corpse.prototype.toString = function()
{
   return "[object EVR.Animation.Ending.Corpse]";
}
216.73.216.51
216.73.216.51
216.73.216.51
 
September 13, 2013

from array import array
from time import sleep

import pygame
from pygame.mixer import Sound, get_init, pre_init

class Note(Sound):

    def __init__(self, frequency, volume=.1):
        self.frequency = frequency
        Sound.__init__(self, self.build_samples())
        self.set_volume(volume)

    def build_samples(self):
        period = int(round(get_init()[0] / self.frequency))
        samples = array("h", [0] * period)
        amplitude = 2 ** (abs(get_init()[1]) - 1) - 1
        for time in xrange(period):
            if time < period / 2:
                samples[time] = amplitude
            else:
                samples[time] = -amplitude
        return samples

if __name__ == "__main__":
    pre_init(44100, -16, 1, 1024)
    pygame.init()
    Note(440).play(-1)
    sleep(5)

This program generates and plays a 440 Hz tone for 5 seconds. It can be extended to generate the spectrum of notes with a frequency table or the frequency formula. Because the rewards in Send are idealized ocean waves, they can also be represented as tones. Each level has a tone in its goal and a tone based on where the player's disc lands. Both play at the end of a level, sounding harmonic for a close shot and discordant for a near miss. The game can dynamically create these tones using the program as a basis.

I'm also building an algorithmically generated song: Silk Routes (Scissored). Here is an example of how it sounds so far.