Pd signal streaming objects

Use streamout~ and streamin~ to stream audio over a local network

The ‘help file’ for streamout~ has an example. Change ‘localhost’ in the connect message to the local IP address of the target.

Granular time stretching in Max

Adaptation of Andy Farnell’s Pd granular timestretch patch

Adjustable chunk-size, pitch, and speed – as well as manual scrubbing.

The original Pd patch (timestretch.pd) is available here: http://aspress.co.uk/sd/index.php

download

https://github.com/tkzic/max-projects

folder: granular-timestretch

patches

  • timestretch5.maxpat (main patch)
  • tabread4~.maxpat (Pd abstraction) 
  • hip~.maxpat (Pd abstraction)

How it works

An index pointer (file phasor) scans from the beginning to the end of the file. For example, at 44.1KHz, a 1 second file of audio would have 44,100 samples. Each sample is 022676 ms. Another phasor (grain phasor) scans small chunks (grains) of audio. If audio is playing back at the normal rate and pitch, this grain phasor runs at zero. the file phasor just moves sequentially from one grain to the next.

To stretch the time, the file phasor is slowed down, but the grain phasor speeds up, scanning grains of audio, that start at the current file phasor index. In this way, in listening to the file from beginning to end, you are actually listening to a series of overlapping grains.

As the chunk (grain) size increases the grain phasor frequency decreases.

To raise the pitch, the grain phasor frequency would be increased. To lower the pitch, the phasor frequency goes negative and increases in a negative direction to reduce pitch further.

As you can see, while running this patch, the chunk size, pitch, and speed are all related by a single equation.

phasor frequency = ((pitch / 120)**2 – speed) / chunksize

  • where pitch is in cents (0 is normal)
  • speed is a scaling factor (1 is normal)
  • chunk (grain) size  is in ms.

So the input values interact with each other.

In addition, the grain player uses a technique called PSOLA. Pitch synchronous overlap and add. There are actually two grain players playing simultaneously 180 degrees out of phase. Each is windowed using a positive cosine function. This helps to reduce clicks by crossfading from one grain to the next.

There is some comb-filtering and ringing present on the audio. There are various techniques to reduce this, including:

  • trying different window functions
  • higher sample rates
  • changing the overlap
  • varying the grain size
Interesting artifacts:
  • reducing the grain size to several ms. causes oscillation similar to the Karplus-Strong effect
  • increasing the grain size to around 1000 ms. causes a feedback delay effect due to the out of phase grain players
  • setting the overlap to anything other than .5 causes random phase cancellation
Manual or automated scrubbing.

There is also an option to manually scrub the file. This way you can listen to the texture of grains of various sizes from various points in the file.

You can also set random automatic scrubbing to branch to various points in the file.

rtlsdr, Pd, linux

notes

Today was able to get the rtlsdr~ object running in Pd on Ubuntu 14.04 on a Macbook pro.

Audio quality seems rough. The only driver I could get to work was Alsa at 44.1KHz – may be able to get help with this from Pd community.

Ended up using 64bit libraries for librtlsdr and libusb-1.0 . In fact, needed to using the shared (.so) libraries, not the static ones (.a) due to a weird linker error. Its possible that it happened due to mixing shared and static and I might try again using both static for these 2 libs.

See notes from previous post about issues with USB capture, and non-root user in Linux – there are 2 flags on the cmake for rtlsdr that might help resolve both of these, but I wasn’t having any luck and needed to use the method described in previous post.

The source code for linux version is in the /usr/lib/pd-extended/extra/rtlsdr~ folder – and the test pd file is in ~/pd/rtlSDR-block.pd, along with some abstractions.

There is also a makefile to build a local version of rtl_fm (rtl_fm3.c) in ~/rtl-sdr-new/rtl-sdr/rtl-fm3/

This makefile mixes the static and shared libs with no problem… hmm…?

next

Need to package this stuff up and send it to pdsdr github with source for Max/Pd on mac and Pd on linux. + instructions… etc.,

Would like to try running on r-pi – but will need to adapt the test patch to receive Osc messages because there is no gui on r-pi

Also I am some skeptical about running at low sample rates for audio – we’ll see…

another note

Just thinking, that even if I am not able to run rtlsdr~ on r-pi that we could adapt rtl_fm so it receives control input from Pd using Osc and work that way…

 

Installing Ubuntu Linux 14.04 on MacBook Pro – dual boot

updated 3/17/2017 – for Sierra 10.12.3

  1. download latest version of refind (0.10.5) https://sourceforge.net/projects/refind/?source=typ_redirect
  2. unzip and copy folder under home directory
  3. restart computer and hold down cmd-R
  4. go to utilities and start a terminal session
  5. cd to the refind directory created above. (look under Volumes/Macintosh HD/Users/…
  6. run ./refind-install
  7. reboot

updated 6/18/2015 – For Yosemite

For upgrade to Yosemite, just get the newest version of refined (0.8.7) and rerun the install script. It will find the existing linux partition.

One annoying thing is that on restart it displays 3 separate versions of the same boot loader.

update 8/13/2014

Installed on new Macbook Pro retina and needed to use an earlier version of refind (0.7.8) than the one currently available. When running the newest version – it couldn’t see the USB stick with ubuntu. Also did not need to install the wifi drivers.

Another note: here are instructions for NVIDIA drivers. Though I haven’t tried them yet:

http://cberner.com/2014/04/20/installing-ubuntu-14-04-on-macbook-pro-retina/

The whole user experience on the Retina Macbook is so far not as good as on the older 2011 version. Problems with trackpad, mouse, and display.

update 4/25/2014 – how to repair dual boot after MacOS automatic update to 10.9.2

After an automatic update to 10.9.2 – the EFI boot menu disappeared. Solution is to just re-install rEFInd using the ./install.sh script as shown here, as in the original installation:

The installation needs to be done in the Terminal, by running the install.sh script:

cd ~/refind-bin-0.7.8
./install.sh --alldrivers
Then reboot...

Original post

This took several attempts to get right. So here are notes.

First – Make sure you have a Time Machine backup. You will probably need it.

The thing that worked was a combination of these two posts.

For the most part, use these instructions:

http://randomtutor.blogspot.com/2014/01/installing-ubuntu-on-retina-macbook-pro_19.html

One thing that was weird is that you reboot with the USB installer plugged in you get several boot choices with no explanation. You can choose the first one, but make sure to select “Try Ubuntu” and install according to above instructions…

note: I did not need to do step 5 – editing the refind config file.

But you may also need to get the wiFi drivers as explained here – just don’t follow the install instructions or you will trash your bootloader:

http://www.alexvictorchan.com/2013/05/01/installing-ubuntu-13-04-on-13-macbook-pro-retina-102/

Then you will probably want to do the first few of these suggestions to get Media playback:

http://itsfoss.com/things-to-do-after-installing-ubuntu-14-04/

For Pd-extended install – just use instructions from the Pd site

http://puredata.info/docs/faq/debian

(I ran the terminal commands with the ssh keys to get it, because It wasn’t in the Ubuntu software center)

 

 

Software Defined Radio in Pd

This is based on the Max tutorials. I have only written one external (for Soft66LC2). But everything seems to be working well with minimal filtering. After watching the video, I think the next feature should be an AGC (automatic gain control) on the input stage.