## Inspiration

When walking to school every day, we often find that the music playlists we've made usually don't match the emotion or the rhythm of our walk. On some days, our steps would be bright and energetic, while shuffling a playlist would often lead us to off-beat, melancholic songs.

This observation sparked an idea: What if there was a way to bridge this gap? To create a seamless blend of movement and music, where one could influence the other? From this, "Pedal to the Metal" was born. It isn't just about syncing steps with songs; it's about capturing the essence of a moment, the emotion behind each stride, and translating it into a musical experience.

This project was inspired by the simple belief that our movements, both conscious and subconscious, are a reflection of our emotions. And what better way to amplify those emotions than with the perfect soundtrack! Every step and every emotion has its unique melody, making every journey, no matter how mundane, a rhythmic adventure.

## What it does

"Pedal to the Metal" is an application that utilizes a device's accelerometer data to perform gait analysis and recommend music based on that data. Initially, raw data is collected as a device is in a user's pocket while walking. From there, the raw data is segmented and classified into one of four emotions: Happy, Sad, Chill, and Angry. Each emotion is associated with 5 genres of music (for example, Happy = ['acoustic', 'bossanova', 'disco', 'funk', 'reggae'] ). After receiving this data, Spotify's API recommends music correlated to those genres. All of this is brought together via the Android application!

## How we built it

To go about creating this product, we begin by feeding segmented smartphone accelerometer data to a model. This model then evaluates the given data using a three-layer neural network to classify it into one of the four main emotions: Happy, Sad, Chill, and Angry. Each emotion is correlated to 5 genres on Spotify's list of genres. We then connected to the Spotify API to generate song recommendations. Lastly, the Android application serves as a front end to provide a sleek interface for the user.

## Challenges we ran into

We ran into many challenges when implementing this project mainly because most of the information online was theoretical and not implemented in code. Thus, simple tasks like segmenting the raw data and figuring out how to handle the data transfer from the phone to the server were mainly done through trial and error. Although this was the case, we would eventually find great solutions to the many obstacles faced throughout this development!

## Accomplishments that we're proud of

Accelerometer Data - Accessing accelerometer data was a great moment for us since it was our first obstacle and it shed a bit of light on how we would handle the data throughout the process.

Creating our data - Generating a data set through walking was not only a fun experience, but we also had a fun time exploring the UWaterloo campus while also being productive.

Using the Spotify API - It was very fun to explore the Spotify API documentation and see how the recommendation system worked.

Android Development - Android development felt like extraterrestrial land to us. None of us knew how to develop applications, yet we were able to figure out how to get one up and running within about 15 hours.

## What we learned

During these 36 hours, we learned so much! We learned how to work with RNNs, deep-learning technology, app development, problem-solving techniques, and more.

## What's Next for Pedal To The Metal

Gait analysis as a concept has a bright future ahead. Similarly, Pedal to the Metal has many opportunities for feature implementations.
An example of such features includes a way to connect to a Spotify account to provide a more refined recommendation system.
## Inspiration

Research has demonstrated that music when synchronized with a person's running cadence can provide enhanced psychological and psychophysical benefits during running. As a group of runners, we thought it would be very useful to have an app that would pick up music that matched the current pace of our strides, in order to motivate us to push through our runs. We took this hackathon as an opportunity to explore this interesting idea!

## What it does

Our system leverages the smart devices that people wear/possess while running to measure their running cadence. Once we process and clean these metrics, we wire them to a mobile application. This app links the user's Spotify account with our system and allows the user to pick between their various playlists (ideally with songs that vary in tempo!) that they want to listen to on their run. Then, once the user starts running, the application plays songs that matches the user's running tempo in real time.

## How we built it

We decided to leverage the IMU sensor on the iPhone to measure the user's cadence. We leverage the fact that many people run with either their phone or their Apple Watch to track their workouts, and both of these devices have IMU sensors that we can access. Although the current system is built for the iPhone, adding watch support should be relatively straightforward. We use a python backend server to process the raw signal data received from the IMU and compute the user's running cadence using Fourier transforms. On the mobile app, we use the Spotify API to access the user's playlists, find the tempo of the songs, and play songs that match the user's running pace in real time. Our app frontend is developed using UIKit. We also leveraged the Cerebras AI API to allow users the option to play music via an unstructured chat request (i.e. "I want to feel positive on this run!"), rather than select playlists on their own.

## Challenges we ran into

As all of us were beginner iOS Developers, we faced several blockers initially while getting accustomed with the XCode IDE, Swift, version control, as well as UIKit (the Swift framework used to structure the application).

This project dealt with several complex technologies/methods, ranging from OAuthentication via Spotify's iOS SDK, Fourier Transforms calculation to determine real-time cadence calculation from accelerometer data, alongside generative AI prompting for further music personalization. Understanding how to incorporate each of these elements into the chassis of our project required deep research documentation and practiced methods.

## Accomplishments that we're proud of

* Applying knowledge from multiple disciplines (sensor technology, data science, AI, and music theory) to create a cohesive product,
* Using Apple's CoreMotion library capture real-time movement data from iPhone's IMU sensors,
* Processing raw sensor data to accurately determine user's steps per minute,
* Leveraging Spotify's iOS SDK and Web APIs to fetch music data, then song to match running cadence,
* Building the entire application in the legacy UIKit framework, which was necessary as the Spotify iOS SDK was not compatible with SwiftUI,
* Experimenting with GenAI to curate playlists based on the user's mood,
* Hopefully paving the way for people to get into running and improving their physical health!

## What we learned

We learned how to develop apps in UIKit - this was the first time coding in IOS for most of us. We grew a much deeper understanding of the Model-View-Controller architecture, alongside Spotify's API (iOS SDK & Web API). Of course, we also learned of the merits of working towards an idea that we were all deeply connected to and passionate about!

## What's next for Stryde

Here are a few things that we would have liked to seen implemented in the future when we are not under a time constraint:

* User defined cadence duration
Give users an option to select their target cadence and how long they want to run at for each pace. The system then plays music at that tempo for the given time periods. This way, users have an easy way to determine how fast they should be going and to stay on track with their goals instead of having to estimate their pace.
* More educational options
We hope to expand this system to be educational and encourage more new runners to get into the activity. This could include system optimizations to recommend different running cadences that users may want to aim for if they do not have a great sense of how fast they should be going. We could also track user's running cadence progression - along with other metrics obtained from various health sensors available on smart devices - and act as a coach or guide.
## Inspiration

We’re huge fans of Spotify, but we’ve always hoped there were more filters for our liked songs outside of just album, artist, and song title. What if we could instead filter by what mood, or “vibe” each song represents? Vibe's got you covered.

## What it does

Vibe, powered by Wolfram AI, analyzes your musical tastes and gives you a holistic overview of your top Spotify songs. It creates a custom playlist for you from your top songs, based on your current mood.

## How I built it

Vibe leverages the Spotify API and our own sentiment analysis to get the musical and lyrical attributes of each top song in your Spotify account. We then trained a machine learning classifier API using the Wolfram Platform (Wolfram One Instant API) to classify the "vibe" of a song according to its attributes. The training data for this classifier was obtained from publicly available Spotify playlists that were tagged with a specific mood.

For the frontend, both React and Bootstrap were used. For the backend, we used the Wolfram One platform for the classifier, while the sentiment analysis was built with a Python/Flask stack, the Genius API to get urls of song lyrics, BeautifulSoup4 to web scrape the lyrics, and vaderSentiment to carry out sentiment analysis.

## Challenges I ran into

This is the first time we've used flask and Wolfram, and it was interesting to learn about these new technologies while navigating through the difficulties.

## Accomplishments that I'm proud of

Using new technologies!

## What I learned

Sentiment analysis, wolfram, flask

## What's next for for Spotify

We hope to:

* improve our analysis/machine-learning metrics
* raise the accuracy of our model by introducing 10x more training data
* add more vibes
* build a similar app for Apple Music