本文整理汇总了Python中track.Track类的典型用法代码示例。如果您正苦于以下问题:Python Track类的具体用法?Python Track怎么用?Python Track使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Track类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: add_track
def add_track(self, loc, trackdb):
track = trackdb.get_track_by_loc(loc)
if not track:
track = Track(loc)
respone = trackdb.add_track_from_trackobj(track)
if not respone:
return False
tr_album = track.get_tag_raw('album', True)
tr_albumartist = track.get_tag_raw('albumartist', True)
if tr_albumartist == u'':
tr_albumartist = track.get_tag_raw('artist', True)
album = self.get_album_from_info(tr_album, tr_albumartist)
if not album:
# create new album
album = Album(tr_album, tr_albumartist)
self.__albums[(tr_album, tr_albumartist)] = album
album.unchecked_add_song(track)
self.__total_duration += track.get_tag_raw('__length')
# cover = coverdb.get_cover(tr_album, tr_albumartist)
# if not cover:
# tr_cover = track.get_tag_disk('cover')
# if tr_cover:
# coverdb.add_cover(tr_album, tr_albumartist, tr_cover)
return track
开发者ID:arshavindn,项目名称:Miusik,代码行数:25,代码来源:playlist.py
示例2: loadTrack
def loadTrack(self, trackfilename, track_id, flight_start):
#trackflilename does not include the path, it's only name and extesion
#track = open("./Flight1.txt", "r")
track = Track(track_id)
cont = 0
with open(self.scenariosfolder + "/" + self.scenarioName + "/" + trackfilename, "r") as trackfile:
for line in trackfile:
if (not (line.startswith('#') or line.startswith('/'))) and len(line)>30:
#if cont >= 4 and len(line)>30:
parts = line.split()
timestamp = parts[0]
lat = float(parts[1])
lon = float(parts[2])
altitude = float(parts[3])
heading = float(parts[6])
v_x = float(parts[8])
v_y = float(parts[10])
v_z = float(parts[9])
pitch = float(parts[4])
bank = float(parts[5])
onground = int(parts[7])
airspeed = float(parts[19])
track.addStep(timestamp, lat, lon, altitude, v_x, v_y, v_z, heading, pitch, bank, onground, airspeed)
#track.addStep(timestamp, lat, lon, altitude, v_x, v_y, v_z, heading, pitch, bank)
#cherrypy.log("%s,%s,%s,%s,%s,%s,%s,%s"%(timestamp, lat, lon, altitude, v_x, v_y, v_z, heading),context="EXPORT,")
cont += 1
track.setStart(flight_start)
return track
开发者ID:gluseppe,项目名称:progaserver,代码行数:32,代码来源:automator.py
示例3: initthread
def initthread(mwc, mc):
library = mwc.library
mwc.status_msg("Initializing..")
wc = Webclient()
wc.login(config.user, config.password)
devices = wc.get_registered_devices()
mwc.status_msg("Retrieving usable device ID..")
for dev in devices:
if dev["type"] == "PHONE":
# strip 0x if present
config.devid = dev["id"][2:] if dev["id"].startswith("0x") else dev["id"]
print("Found a usable device id: " + config.devid)
break
else:
md = Gtk.MessageDialog(parent=mwc.ui, buttons=Gtk.ButtonsType.OK, message_type=Gtk.MessageType.ERROR, message_format="Could not find a usable device id. Please run the Google Play Music app at least once on your phone.")
GLib.idle_add(modal_dialog_func, md)
mc.login(config.user, config.password)
player = Player(mc, config.devid)
mwc.setplayer(player)
def getalbumart(structure):
if "albumArtRef" in structure:
a = structure["albumArtRef"]
for entry in a:
if "url" in entry:
return entry["url"]
return None
mwc.status_msg("Retrieving library..")
songs = mc.get_all_songs()
for song in songs:
track = Track(song["id"], song["title"], song["artist"], song["album"],
song["trackNumber"] if "trackNumber" in song else 0)
track.albumarturl = getalbumart(song)
library.add_track(track)
mwc.status_msg("Retrieving playlists..")
playlists = mc.get_all_user_playlist_contents()
for x in playlists:
tracks = []
for t in x["tracks"]:
if t["trackId"].startswith("T"): # all access track
trackEntry = t["track"]
track = Track(t["trackId"], trackEntry["title"], trackEntry["artist"], trackEntry["album"], trackEntry["trackNumber"])
track.albumarturl = getalbumart(trackEntry)
tracks.append(track)
else:
libtrack = library.find_track(t["trackId"])
if libtrack is not None:
tracks.append(libtrack)
library.add_list(Playlist(x["name"], tracks))
mwc.status_msg("Idle")
开发者ID:hrkfdn,项目名称:gomusic,代码行数:58,代码来源:main.py
示例4: row_to_entity
def row_to_entity(row):
spot_entity = Spot()
spot_entity.id = row.id
spot_entity.name = row.name
spot_entity.position = GeoPoint.row_to_object(row.position)
spot_entity.tags = row.tags
spot_entity.tracks_current = [Track.row_to_object(track_row) for track_row in row.tracks_current]
spot_entity.tracks_old = [Track.row_to_object(track_row) for track_row in row.tracks_old]
return spot_entity
开发者ID:jacekdalkowski,项目名称:bike-timer,代码行数:9,代码来源:spot.py
示例5: __init__
def __init__(self, fn, name="Song name", cache_dir=None,
refresh_cache=False, labels=None, labels_in_file=False):
self._analysis = None
self._checksum = None
self.refresh_cache = refresh_cache
self.cache_dir = cache_dir
Track.__init__(self, fn, name, labels=labels,
labels_in_file=labels_in_file)
开发者ID:Morphinity,项目名称:retarget_modified,代码行数:9,代码来源:song.py
示例6: filter
def filter(self, dt, z, R):
associated = [track.filter(dt, z, R) for track in self.tracks]
if not any(associated):
new_track = Track(filter_model=self.filter_factory())
new_track.filter(dt, z, R)
self.tracks.append(new_track)
开发者ID:michaelbratsch,项目名称:kalman,代码行数:10,代码来源:tracker.py
示例7: parse_response
def parse_response(self, response_json):
playlist = []
# used to get rid of duplicate tracks in same album
album_set = Set()
parsed_json = json.loads(response_json)
# first check if the json can be correctly parsed
if not 'tracks' in parsed_json:
return all_tracks
json_tracks = parsed_json['tracks']
for json_track in json_tracks:
track = Track()
curTrackMap = {}
album = json_track['album']['name'].lower()
if album in album_set:
continue
album_set.add(album)
track.set_album(album)
track.set_name(json_track['name'].lower())
artists = json_track['artists']
artists_name = []
for artist in artists:
artists_name.append(artist['name'].lower())
track.set_artists(artists_name)
track.set_length(json_track['length'])
playlist.append(track)
return playlist
开发者ID:guoyu1989,项目名称:SpotifyPoem,代码行数:29,代码来源:spotify_client.py
示例8: get_track
def get_track(provider_id):
t = Track()
try:
######MediaNet######
# reqUrl = 'http://ie-api.mndigital.com?method=track.get&format=json&'\
# + urllib.urlencode({'mnetid': provider_id})\
# + '&ApiKey=%s' % MusicProvider._mnDigitalIntegrationAPIKey
reqUrl = "http://itunes.apple.com/lookup?" + urllib.urlencode({"id": provider_id})
# track_json = common.get_json(reqUrl)["Track"]
track_json = common.get_json(reqUrl)["results"][0]
t.provider_id = provider_id
t.length_seconds = 0
t.url = ""
# t.artist = track_json["Artist"]["Name"]
# t.title = track_json["Title"]
# t.length_friendly = track_json["Duration"]
# t.album = track_json["Album"]["Title"]
# t.art_url = track_json["Album"]["Images"]["Album150x150"]
t.artist = track_json["artistName"]
t.title = track_json["trackName"]
t.length_friendly = ""
t.album = track_json["collectionName"]
t.art_url = track_json["artworkUrl100"]
except Exception:
pass
return t
开发者ID:chrisclark,项目名称:msfm,代码行数:31,代码来源:musicProvider.py
示例9: play
def play(self, position = 0, onError = None):
if len(self.tracks) > 0 and len(self.tracks) > position:
self.position = position
if onError == None:
self.currentTrack = Track(self.tracks[self.position])
else:
self.currentTrack = Track(self.tracks[self.position], onError)
self.currentTrack.setVolume(self.volume)
self.currentTrack.play()
else:
raise IndexError('Wrong track position')
开发者ID:Palkovsky,项目名称:AudioPi,代码行数:11,代码来源:playlist.py
示例10: index
def index(self, path):
for top, dirnames, filenames in os.walk(path):
for filename in filenames:
if filename.endswith('.mp3'):
full_path = os.path.join(top, filename);
f = tagpy.FileRef(full_path)
t = Track("file://" + full_path)
t.title = f.tag().title
t.artist = f.tag().artist
t.album = f.tag().album
a = f.audioProperties()
t.duration = a.length * 1000 # to msec
self.add_track(t)
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:13,代码来源:collection.py
示例11: output_aligns
def output_aligns(outfile, aligns, track_name=None, contigs=None, append=False,
header=True, genome=None, refseq=None, color=None, by_fasta=False, annodir=None):
"""Outputs alignments to file"""
ext = os.path.splitext(outfile)[1]
if append:
out = open(outfile, 'a')
else:
out = open(outfile, 'w')
# desc == name
track_desc = track_name
if aligns:
if track_name and genome:
Track.ucsc_targets(genome, aligns, annodir)
if header and track_name:
header_line = "track name=\"%s\" description=\"%s\" visibility=%d itemRgb=\"On\"" % (track_name, track_desc, 3)
if color is not None:
header_line += ' color=\"%s\"' % (color)
out.write("%s\n" % (header_line))
# map contig to contig name
contig_dict = None
if contigs:
contig_dict = dict((contig.num, contig) for contig in contigs)
# sort alignments by contig order in original input fasta file
if by_fasta:
count = 0
ordered = {}
for contig in contigs:
ordered[contig.num] = count
count += 1
aligns.sort(lambda x,y: ordered[x.query] - ordered[y.query])
for align in aligns:
contig = align.query
if ' ' in contig:
contig = align.query.split(" ")[0]
if contig_dict and contig_dict.has_key(contig):
align.contig = contig_dict[contig]
if ext == ".gff":
out.write(align.gff("exon"))
elif ext == ".psl":
out.write(align.psl(refseq=refseq, genome=genome))
out.close()
开发者ID:sara62,项目名称:transabyss,代码行数:50,代码来源:align_parser.py
示例12: App
class App(Tk):
def __init__(self, ftimer):
Tk.__init__(self)
self.sats = Track()
self.sats.load_local("data.txt") # to be changed
self.sats.add_satellite(7) # achtung, hardcode
menu = UserMenu(parent = self)
self.config(menu = menu)
self.title('SatKit Ground Tracking')
self.timer = ftimer
self.timer.callback_function = self.redraw
self.time_speed = 1 # normal speed
self.var = IntVar()
self.scale = Scale(self, variable = self.var, from_ = 1, to = 3600,
orient = HORIZONTAL, showvalue=0, sliderlength=15,
length=400, command=self.set_time_speed)
self.date = Label(self)
def redraw(self):
self.timer.set_speed(self.time_speed) # bad, should be improven,~event
self.sats.update_satellites(self.time_speed * Time.TIMER_INTERVAL)
#print self.time_speed
# recompute "current" time, later,,,
self.date.config(text = str(self.timer.current_time)[0:21])
self.date.grid(row = 0, column = 1)
self.scale.grid(row = 0, column = 0)
self.sats.anim.grid(row = 1, columnspan = 2)
self.sats.draw()
def set_time_speed(self, secs):
self.time_speed = int(secs)
开发者ID:TUM-FAF,项目名称:SatKit,代码行数:35,代码来源:moin.py
示例13: get_track_row
def get_track_row(self):
row = self.db.fetchone()
tid = row['track_id']
position = row['position']
ptid = row['id']
self.db.commit_statement('''select * from tracks where id = ?''', [row['track_id']])
row = self.db.fetchone()
del row['id']
t = Track(**row)
t.id = tid
t.position = position
t.ptid = ptid
return t
开发者ID:estock,项目名称:dogvibes,代码行数:14,代码来源:playlist.py
示例14: get_track_row
def get_track_row(self):
row = self.db.fetchone()
tid = row["track_id"]
position = row["position"]
ptid = row["id"]
self.db.commit_statement("""select * from tracks where id = ?""", [row["track_id"]])
row = self.db.fetchone()
del row["id"]
t = Track(**row)
t.id = tid
t.position = position
t.ptid = ptid
return t
开发者ID:popdevelop,项目名称:dogvibes_old,代码行数:14,代码来源:playlist.py
示例15: CyclopsEvolver
class CyclopsEvolver(TournamentEvolver):
def __init__(self, popSize, tournSize, nIters):
super().__init__(popSize, tournSize, nIters)
self.track = Track()
self.simDuration = self.track.size * 4
self.startSeed = random.random()
def randomIndividual(self):
nNeurons = 8
return System(nNeurons)
def mutated(self, system):
return self.mutatedPartial(system, 1, 8)
def mutatedPartial(self, system, mean, variance):
sys = system.copy()
#sys.trans += variance / 4 * numpy.random.randn(*sys.trans.shape)
sys.trans *= mean + variance * numpy.random.randn(*sys.trans.shape)
#sys.trans += 1/8 * numpy.random.randn(*sys.trans.shape)
return sys
def fitness(self, system):
return sum(self.fitness1(system, self.startSeed + i) for i in range(64))
def fitness1(self, system, seed):
distances = []
def distanceTracker(track):
rawDist = track.bot.position - track.flag.position
dist = min(rawDist % track.size, (-rawDist) % track.size)
distances.append(dist)
self.simulate(system, distanceTracker, seed)
return -sum(d for d in distances[-self.track.size : ])
def simulate(self, system, watcher, seed=None):
# initialize conditions
self.track.reset(seed)
system.reset()
# simulate
for iteration in range(self.simDuration):
self.track.step(system)
watcher(self.track)
def animate(self, system):
frames = []
def frameCapturer(track):
frames.append(track.drawnState())
self.simulate(system, frameCapturer)#, self.startSeed)
return frames
开发者ID:ksb2266,项目名称:body-babble,代码行数:49,代码来源:mangledcyclops.py
示例16: __init__
def __init__(self, width, height):
self.controls = None
self.round_manager = RoundManager(self)
self.ui_font = font.Font("./fonts/FreeSansBold.ttf", 12)
self.round_label_font = font.Font("./fonts/FreeSansBold.ttf", 20)
self.mouse_position = (0, 0)
self.placing_tower = False
self.selected_place_tower = build_tower(self, BALLISTA_TOWER)
self.selected_active_tower = None
self.ui_tower_image = build_tower(self, BALLISTA_TOWER).image
self.generate_tower_placement_sprite()
self.tower_select_index = 0
self.money = 20000
self.lives = 50
self.start_tile = 16, 16
self.width, self.height = width, height
self.entities = pygame.sprite.Group()
self.towers = pygame.sprite.Group()
self.projectiles = pygame.sprite.Group()
self.explosions = pygame.sprite.Group()
total_level_width = width*16
total_level_height = height*16
self.generate_background_image()
self.track = Track()
self.camera = Camera(complex_camera, total_level_width, total_level_height)
开发者ID:brandr,项目名称:Tower_Defense,代码行数:25,代码来源:level.py
示例17: createNewTracks
def createNewTracks(self, detections, unmatchedDetections):
for detectionIndex in unmatchedDetections:
detection = detections[detectionIndex]
array_detection = np.array(detection, np.float32)
# TODO: Create Kalman filter object
kf = cv2.KalmanFilter(4, 2)
kf.measurementMatrix = MEASUREMENT_MATRIX
kf.transitionMatrix = TRANSITION_MATRIX
# kf.processNoiseCov = PROCESS_NOISE_COV
# Create the new track
newTrack = Track(self.nextTrackID, kf)
newTrack.update(array_detection)
newTrack.locationHistory.append(detection)
self.tracks.append(newTrack)
self.nextTrackID += 1
开发者ID:kaledj,项目名称:bee_video,代码行数:16,代码来源:kalman_track.py
示例18: remove_track
def remove_track(self, loc, trackdb):
"""
Remove song from playlist with given location.
"""
track = trackdb.get_track_by_loc(loc)
if not track:
track = Track(loc)
if not track._scan_valid:
return False
tr_album = track.get_tag_raw('album', True)
tr_albumartist = track.get_tag_raw('albumartist', True)
if tr_albumartist == u'':
tr_albumartist = track.get_tag_raw('artist', True)
album = self.get_album_from_info(tr_album, tr_albumartist)
if not album:
return False
return album.remove_track(loc)
开发者ID:arshavindn,项目名称:Miusik,代码行数:17,代码来源:playlist.py
示例19: TrackThreader
class TrackThreader():
def __init__(self):
self.track = None
self.onEndCustomCallback = None
self.volume = volumizer.getJSON()['config']['milli']
def __play_track(self, track, callback = None):
self.setVolume(volumizer.getJSON()['config']['milli'])
if(callback == None):
track.play()
else:
callback(track)
self.__oversee_track(track)
#This makes track to disapear after it's done playing
def __oversee_track(self, track):
while (track.isBusy() or track.isPaused()) and not track.shouldEnd():
continue
if(self.onEndCustomCallback == None):
if(self.track != None):
print(self.track.getPath() + " finished playing.")
self.setTrack(None)
else:
self.__play_track(track, self.onEndCustomCallback)
def getThread(self, path):
self.track = Track(path, self.volume)
self.playingThread = threading.Thread(target = self.__play_track, args=(self.track, ))
self.playingThread.daemon = True
return {'thread' : self.playingThread,
'track' : self.track}
def currentTrack(self):
return self.track
def setTrack(self, track):
self.track = track
def setVolume(self, volume):
self.volume = volume
if self.track != None:
self.track.setVolume(volume)
def registerOnEndCustomCallback(self, callback):
self.onEndCustomCallback = callback
开发者ID:Palkovsky,项目名称:AudioPi,代码行数:45,代码来源:threader.py
示例20: as_list
def as_list(path: str, pattern: str, default_artist="", default_title="", type="song"):
file_list = []
for file_path in Path(path).glob(pattern):
try:
file_list.append(
Track.from_path(str(file_path), default_artist, default_title, type=type, raise_error=False)
)
except (KeyError, IOError) as err:
print(err)
return file_list
开发者ID:uamana,项目名称:splist,代码行数:10,代码来源:loader.py
注:本文中的track.Track类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论