{"id":342,"date":"2021-03-13T18:19:36","date_gmt":"2021-03-14T03:19:36","guid":{"rendered":"http:\/\/eequalspi.com\/?p=342"},"modified":"2021-03-13T18:19:36","modified_gmt":"2021-03-14T03:19:36","slug":"pivideomusic","status":"publish","type":"post","link":"https:\/\/eequalspi.com\/index.php\/2021\/03\/13\/pivideomusic\/","title":{"rendered":"PiVideoMusic"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/i.imgur.com\/Stqb5ZV.png\" alt=\"\"\/><figcaption>Still shot<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-rich is-provider-embed-handler wp-block-embed-embed-handler\"><div class=\"wp-block-embed__wrapper\">\n<div style=\"width: 640px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-342-1\" width=\"640\" height=\"360\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/i.imgur.com\/NZDQjBa.mp4?_=1\" \/><a href=\"https:\/\/i.imgur.com\/NZDQjBa.mp4\">https:\/\/i.imgur.com\/NZDQjBa.mp4<\/a><\/video><\/div>\n<\/div><figcaption>Silent clip of the PVM in action. Youtube linked below.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Years and years ago, I heard about the AtariVideoMusic. A short lived music visualization device created by Atari in the late 70&#8217;s. It would hook up to your home hi-fi and living room TV and show off the music. <a href=\"https:\/\/www.youtube.com\/watch?v=wle0eqBwtL8\">Techmoan did a good introduction to it here<\/a>, but imagine a very primitive version of <a href=\"https:\/\/en.wikipedia.org\/wiki\/MilkDrop\">MilkDrop<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Anyway, since before the time Techmoan did his review, I have been thinking about creating my own, modern-retro take on the idea. Music visualizers seem to have dropped off the face of the earth in the last few years, but I&#8217;ve always loved them.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Anyway, long story short, a couple of years ago I started making my own. I realized that the Raspberry Pi was the perfect tool for the job. It could easily do all the music visualization I wanted it to, and be built into the stereo component style box with an integrated, tiny, CRT that I envisioned at the time. Fate would have it that my old academic advisor had a tiny portable color television that he gave to me, gratis, and in the course of developing the code, I decided that the TV itself was perfect, so I just put the Raspberry Pi out of sight behind the TV and called it a day.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Video Tour<\/h2>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"PiVideoMusic\" width=\"840\" height=\"473\" src=\"https:\/\/www.youtube.com\/embed\/Tn089Cl4c8I?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Software<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The software is all written in python, and can be <a href=\"https:\/\/github.com\/wespo\/RaspberryVideoMusic\">found here<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are two files, <code>RaspberryVideoMusicSupervisor.py<\/code> and <code>RaspberryVideoMusic.py<\/code>. The former simply makes sure the latter is running as a process. It allows me to automatically recover from the occasional crash and I have set up my Pi to simply launch that script on boot.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>RaspberryVideoMusic.py<\/code> is the main script. It relies on Pygame and Pyaudio. The basic loop is simple. Pyaudio captures audio frames and raises a flag when there&#8217;s new data. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There are some basic data &#8216;services&#8217; available at all times, updated when new data is available. These include things like the audio frame, an FFT of the audio, and a detected signal envelope.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The main loop updates the Pygame display when new data is available. Every few seconds it randomly selects a different foreground and background visualization as well as randomly selected color schemes for each.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Hardware<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The hardware is extremely simple. The display is a portable color CRT TV with a composite input. The audio input is a cheap USB sound card. The only trick is that the Raspberry Pi composite output tends to inject audible display noise into the audio. I fixed that by adding a USB isolator between the Pi and the USB sound card.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Additionally, because the sound card input is a mono mic input, it shorts the left and right channels together, creating a mono signal. That&#8217;s fine for the visualizer (it could pretty easily be hacked to handle stereo input), but it means that there should be a headphone amp between your signal source and the mic input to prevent the Pi from distorting your sound and making it mono.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Years and years ago, I heard about the AtariVideoMusic. A short lived music visualization device created by Atari in the late 70&#8217;s. It would hook up to your home hi-fi and living room TV and show off the music. Techmoan did a good introduction to it here, but imagine a very primitive version of MilkDrop. &hellip; <a href=\"https:\/\/eequalspi.com\/index.php\/2021\/03\/13\/pivideomusic\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;PiVideoMusic&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-342","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/eequalspi.com\/index.php\/wp-json\/wp\/v2\/posts\/342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eequalspi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eequalspi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eequalspi.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eequalspi.com\/index.php\/wp-json\/wp\/v2\/comments?post=342"}],"version-history":[{"count":2,"href":"https:\/\/eequalspi.com\/index.php\/wp-json\/wp\/v2\/posts\/342\/revisions"}],"predecessor-version":[{"id":344,"href":"https:\/\/eequalspi.com\/index.php\/wp-json\/wp\/v2\/posts\/342\/revisions\/344"}],"wp:attachment":[{"href":"https:\/\/eequalspi.com\/index.php\/wp-json\/wp\/v2\/media?parent=342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eequalspi.com\/index.php\/wp-json\/wp\/v2\/categories?post=342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eequalspi.com\/index.php\/wp-json\/wp\/v2\/tags?post=342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}