Kraggy123
Posts: 34
Joined: Wed Feb 28, 2018 5:50 pm

Ultrasonic Theremin Problems

Sat Mar 03, 2018 5:37 pm

Hi I recently bought myself a raspberry pi and decided to try and do the ultrasonic Theremin project. I followed it all correctly but no sound is being produced and I have no idea whether it is working or not.

The project I followed below:
https://projects.raspberrypi.org/en/pro ... c-theremin

W. H. Heydt
Posts: 10737
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Ultrasonic Theremin Problems

Sat Mar 03, 2018 6:35 pm

I think the root of your problem is in the word "ultrasonic". Why you expect to be able to hear it?

W. H. Heydt
Posts: 10737
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: Ultrasonic Theremin Problems

Sat Mar 03, 2018 6:36 pm

W. H. Heydt wrote:
Sat Mar 03, 2018 6:35 pm
I think the root of your problem is in the word "ultrasonic". Why do you expect to be able to hear it?

User avatar
rpdom
Posts: 14976
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Ultrasonic Theremin Problems

Sat Mar 03, 2018 6:40 pm

W. H. Heydt wrote:
Sat Mar 03, 2018 6:35 pm
I think the root of your problem is in the word "ultrasonic". Why you expect to be able to hear it?
Because it produces normal sound frequencies. The ultrasonic part is the sensors that detect hand movement instead of using antenna.

Kraggy123
Posts: 34
Joined: Wed Feb 28, 2018 5:50 pm

Re: Ultrasonic Theremin Problems

Sat Mar 03, 2018 6:52 pm

Rpdom is correct, the sensor is simply ultrasonic the ultrasonic part, the speaker itself will produce normal sounds.

User avatar
rpdom
Posts: 14976
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Ultrasonic Theremin Problems

Sat Mar 03, 2018 7:01 pm

Also I think I will build one of those someday. I already have the ultrasonic sensors :-)

Idahowalker
Posts: 445
Joined: Wed Jan 03, 2018 5:43 pm

Re: Ultrasonic Theremin Problems

Sat Mar 03, 2018 7:17 pm

Kraggy123 wrote:
Sat Mar 03, 2018 5:37 pm
Hi I recently bought myself a raspberry pi and decided to try and do the ultrasonic Theremin project. I followed it all correctly but no sound is being produced and I have no idea whether it is working or not.

The project I followed below:
https://projects.raspberrypi.org/en/pro ... c-theremin
When you did this part:

Code: Select all

while True:
      print(sensor.distance)
      sleep(1)
Did you get a print out of sensor distances?
Without knowing why you are deleting my postings, I will not know how...

Kraggy123
Posts: 34
Joined: Wed Feb 28, 2018 5:50 pm

Re: Ultrasonic Theremin Problems

Sat Mar 03, 2018 7:54 pm

No I never got a print out of the distance

Idahowalker
Posts: 445
Joined: Wed Jan 03, 2018 5:43 pm

Re: Ultrasonic Theremin Problems

Sat Mar 03, 2018 8:06 pm

Kraggy123 wrote:
Sat Mar 03, 2018 7:54 pm
No I never got a print out of the distance
Stands to reason why no sound.

What is the error message you are getting?
Without knowing why you are deleting my postings, I will not know how...

Kraggy123
Posts: 34
Joined: Wed Feb 28, 2018 5:50 pm

Re: Ultrasonic Theremin Problems

Sat Mar 03, 2018 8:29 pm

At the moment I get no error message. It seems to run fine and there is no hint that it's gone wrong somewhere, except with no distances being printed and no sound being played.

Idahowalker
Posts: 445
Joined: Wed Jan 03, 2018 5:43 pm

Re: Ultrasonic Theremin Problems

Sat Mar 03, 2018 10:02 pm

Kraggy123 wrote:
Sat Mar 03, 2018 8:29 pm
At the moment I get no error message. It seems to run fine and there is no hint that it's gone wrong somewhere, except with no distances being printed and no sound being played.
This code:

Code: Select all

while True:
      print(sensor.distance)
      sleep(1)

Change to:

Code: Select all

while True:
      print(sensor.distance)
      print ("did the thing")
      sleep(1)
      
Do you get a print out that reads "did the thing" whiles moving your hand in front of the ultrasonic once every 1.0+ seconds?
Without knowing why you are deleting my postings, I will not know how...

Tzarls
Posts: 224
Joined: Tue Feb 26, 2013 6:59 am

Re: Ultrasonic Theremin Problems

Sun Mar 04, 2018 5:07 am

AFAIK there is a problem with the ultrasonic sensor interface in gpiozero - Basically the sensor won't detect any distance so any project based on distance will not work. I had to develop my own ultrasonic class using Pigpio to make the theremin and other projects work.

Kraggy123
Posts: 34
Joined: Wed Feb 28, 2018 5:50 pm

Re: Ultrasonic Theremin Problems

Sun Mar 04, 2018 5:01 pm

I changed the code to the "did that thing" and It didn't print it or anything else.

Idahowalker
Posts: 445
Joined: Wed Jan 03, 2018 5:43 pm

Re: Ultrasonic Theremin Problems

Sun Mar 04, 2018 5:42 pm

Kraggy123 wrote:
Sun Mar 04, 2018 5:01 pm
I changed the code to the "did that thing" and It didn't print it or anything else.
What are you doing to run the code?
Without knowing why you are deleting my postings, I will not know how...

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: Ultrasonic Theremin Problems

Mon Mar 05, 2018 2:49 am

also the SONIC part of that example seems to be old stuff.
but i try this:
in SONIC Pi (3.0.1)
test soundsystem with a
play 70 [Run]
now use this:

Code: Select all

live_loop :RPI_theremin do
  use_real_time
  a, b, c = sync "/osc/play_this"
  synth :piano, note: a, cutoff: b, sustain: c
end
[Run]

open a IDLE3 new file window

Code: Select all

# from https://projects.raspberrypi.org/en/projects/ultrasonic-theremin/
# but (looks like) gpiozero AND SONIC code not work!

# on SONIC use: and press RUN
"""
# Welcome to Sonic Pi v3.0.1
live_loop :RPI_theremin do
  use_real_time
  a, b, c = sync "/osc/play_this"
  synth :piano, note: a, cutoff: b, sustain: c
end
"""

# on PYTHON3 use
from gpiozero import DistanceSensor
from time import sleep
from random import random

from pythonosc import osc_message_builder
from pythonosc import udp_client

# for one ultrasonic sensor use
#sensor = DistanceSensor(echo=17, trigger=4)

sender = udp_client.SimpleUDPClient('127.0.0.1', 4559)

while True:
      sensor = random()  # for test without ultrasonic only
      note = round(sensor * 80 + 20)
      cutoff = 55
      sustain = 0.5
      print(note,cutoff,sustain)
      sender.send_message('/play_this', [note, cutoff, sustain])
      sleep(1.0)
and [run Module (F5)] ( save the python code )
you should hear every second a different piano note ( for test ) and see the printline of python
try:
synth :supersaw, to get a theremin like sound (instead of PIANO )

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: Ultrasonic Theremin Problems

Mon Mar 05, 2018 5:57 am

use a pygame window and mouse click / drag in it
instead of a ultrasonic sensor...
see a black window and press ( and hold and drag ) mouse in it.

code: here

now a test using VNC android tablet touchscreen on that window was not funny because of the strange VNC mouse options ( screen scrolling)

User avatar
KLL
Posts: 1453
Joined: Wed Jan 09, 2013 3:05 pm
Location: thailand
Contact: Website

Re: Ultrasonic Theremin Problems

Tue Mar 06, 2018 10:00 am

Image
also made a video about it: youtube

Return to “Beginners”