PassUnCount
For the 8th Prompt Of Mathober: Counting, PassUnCount takes Python Data Scraping and SonicPi Sonification to Sort and Count NCAA Assist Leaders who also turn the ball over. Then some tweaking and layering was done.
Poem
Wanting to Make the Pass
But it didn't Make it Through
Try and Try Again
But The Results Don’t Seem to Blend
As the Dribbles Go Fast
And the Squeaks can be Heard From the Shoes
What Pass Selection Do You Choose,
To Finally Make it Through
Audio
IllestPreacha · PassUnCount.MP3
Code
Python - WebScraping and Data Sorting
import sys
import pandas as pd
NCAA_APG = pd.read_html('https://www.cbssports.com/college-basketball/stats/player/assists-turnovers/all-conf/all-pos/leaders/?sortdir=descending&sortcol=apg')
NCAA_APG_DF = NCAA_APG[0]
NCAA_APG_DF.columns
NCAA_APG_Eff = NCAA_APG_DF.loc[(NCAA_APG_DF['A/TO Assists Per Turnover'] > 3)]
NCAA_APG_Not_Eff = NCAA_APG_DF.loc[(NCAA_APG_DF['A/TO Assists Per Turnover'] < 3)]
NCAA_APG_Eff.sort_values(by=['A/TO Assists Per Turnover', 'APG Assists Per Game'], ascending=False)
Python Code - Timer that Speaks to SonicPi
import time
import random as rd
import math
from pythonosc import osc_message_builder
from pythonosc import udp_client
def ncaa(t):
print('\n' + str(NCAA_APG_Not_Eff['TO Turnovers'].iloc[t]))
def countdown(t):
while t:
mins, secs = divmod(t, 60)
timer = '{:02d}:{:02d}'.format(mins, secs)
print(timer, end="\r")
time.sleep(1)
if t % 1 == 0:
ncaa(t)
sender = udp_client.SimpleUDPClient('127.0.0.1', 4560)
sender.send_message('/pattern1', [int(NCAA_APG_Not_Eff['TO Turnovers'].iloc[t]),rd.randint(54,79)])
t -= 1
t = input("Enter the time in seconds: ")
countdown(int(t))
SonicPi
live_loop :phase1 do
use_real_time
a, b, c, d = sync "/osc*/pattern1"
with_fx :flanger, mix: rrand(0.1,0.9) do
use_synth [:beep,:bnoise,:saw,:piano,:piano,:piano].choose
play a
end
end