This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from objc_util import * | |
from ctypes import * | |
from coreaudioconstants import * | |
''' Adapted from https://www.cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html | |
''' | |
AudioUnitRenderActionFlags=c_uint32 | |
OSStatus=c_int32 | |
OSType=c_uint32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
class propertyListener(threading.Thread): | |
'''create a listener on one or more of a view's properties, and dispatches a callback whenever those properties change. | |
NOTE: it is highly recommended that the propertyListener instance is part of s custom view class, and in that class's will_close method, call stop() on the instance. otherwise, it will continue to poll even after the view is closed, and could cause problems later. | |
cosntructor args: | |
view - the view to watch | |
propertylist - list of properties to watch. must be a list even if only one prop, e.g ['frame'] | |
action the callback to call. the function should be of the following form |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://gist.github.com/5212628 | |
# | |
# All-purpose gist tool for Pythonista. | |
# | |
# When run directly, this script sets up four other scripts that call various | |
# functions within this file. Each of these sub-scripts are meant for use as | |
# action menu items. They are: | |
# | |
# Set Gist ID.py - Set the gist id that the current file should be | |
# associated with. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# based on Cethric's image capture gist.... | |
FRAME_PROC_INTERVAL=15 #num frames to skip. 1=go as fast as possible, 5=every fifth frame | |
import ui | |
from objc_util import * | |
import ctypes | |
from objc_util import autoreleasepool | |
AVCaptureDevice = ObjCClass('AVCaptureDevice') | |
AVCaptureDeviceInput = ObjCClass('AVCaptureDeviceInput') | |
AVCaptureVideoDataOutput = ObjCClass('AVCaptureVideoDataOutput') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ctypes import * | |
from objc_util import c | |
AudioUnitRenderActionFlags=c_uint32 | |
OSStatus=c_int32 | |
OSType=c_uint32 | |
class SMPTETimeType(c_uint32): | |
kSMPTETimeType24 = 0 | |
kSMPTETimeType25 = 1 | |
kSMPTETimeType30Drop = 2 | |
kSMPTETimeType30 = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as N | |
import wave, sound, os, ui | |
def get_signal_data(frequency=440, duration=1, volume=32767, samplerate=44100): | |
"""Outputs a numpy array of intensities""" | |
samples = duration * samplerate | |
period = samplerate / float(frequency) | |
omega = N.pi * 2 / period | |
t = N.arange(samples, dtype=N.float) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
''' | |
NOTE: This requires Pythonista 3 | |
Demo of a custom ui.View subclass that embeds a native map view using MapKit (via objc_util). Tap and hold the map to drop a pin. | |
The MapView class is designed to be reusable, but it doesn't implement *everything* you might need. I hope that the existing methods give you a basic idea of how to add new capabilities though. For reference, here's Apple's documentation about the underlying MKMapView class: http://developer.apple.com/library/ios/documentation/MapKit/reference/MKMapView_Class/index.html | |
adapted from original code by omz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#\input texinfo | |
# coding: utf-8 | |
# ui-based iOS port of the turtle module (not 100% compatible with standard library | |
# turtle module, but most things beginners would use should work) | |
import ui | |
from math import * | |
import math | |
import time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scene import * | |
import sound | |
import random | |
import math | |
A = Action | |
mapsprites=['plc:Brown_Block','plc:Dirt_Block','plc:Grass_Block','plc:Plain_Block',] | |
def choose_random_node(): | |
tx=random.choice(mapsprites) | |
sn=SpriteNode(tx) |
NewerOlder