User:Wordfa/oldphonehack: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
 
(81 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<img src="https://pzwiki.wdka.nl/mw-mediadesign/images/a/ab/Oldphonehack.png" style="transform: rotate(90deg); align:center; width:500px;margin:0;padding:0;">
= Press #1 For: =
= Press #1 For: =
<img src="https://pzwiki.wdka.nl/mw-mediadesign/images/6/6f/Old_phonebitmap.png" style="transform: rotate(90deg); width: 59.5mm !important;" class="press1for">


== Description ==
== Description ==
Line 7: Line 6:


== Cookbook ==
== Cookbook ==
=== Parts Required ===
=== Parts Required ===
'''USB interface to 3.5mm'''
* [https://www.adafruit.com/product/1475 USB interface to 3.5mm]
 
* 3.5mm Cables
https://www.adafruit.com/product/1475
* [https://www.marktplaats.nl/v/telecommunicatie/vaste-telefoons-niet-draadloos/m2158407457-ptt-t65-goed-werkende-nostalgische-telefoon Old phone (T65)]
 
* Raspberry Pi
'''3.5mm Cables'''
* TRS 3.5 Jack x2
 
* Loads of wires
'''Old phone (T65)'''
* old headphones with a mic ([https://macrepair.nl/wp-content/uploads/2021/10/Apple-Earpods-3.5mm-audio-jack.png apple earpod works best])
 
https://www.marktplaats.nl/v/telecommunicatie/vaste-telefoons-niet-draadloos/m2158407457-ptt-t65-goed-werkende-nostalgische-telefoon
 
'''Raspberry Pi'''
 
'''TRS 3.5 Jack x2'''
 
'''Loads of wires'''
 
'''old headphones with a mic ([https://macrepair.nl/wp-content/uploads/2021/10/Apple-Earpods-3.5mm-audio-jack.png apple earpod works best])'''


=== Things we done ===
=== Things we done ===
- We got one phone from ScrapXL Rotterdam and one from Marktplaats. The first one was a T65 [[File:10-11-t65.jpg|thumb|300x300px|[11 (Neg), 12(Pos) speaker output]]]
- We got one phone from ScrapXL Rotterdam and one from Marktplaats. The first one was a T65  
[[File:D7deb106-88f9-45eb-a34c-7463b6dd9089.jpg|thumb|We ]]
<ul class="gallery">
 
<li style="display: inline-block;">[[File:10-11-t65.jpg|thumb|300px|11 (Neg), 12(Pos) speaker output]]</li>
- We took the phone apart and got the speaker to work by connecting the blue and red cables from the phone out to the audio jack to the soundcard to the computer. played show me the body, was good.
<li style="display: inline-block;">[[File:D7deb106-88f9-45eb-a34c-7463b6dd9089.jpg|thumb|150px|We tried batteries for the carbon mic, didn't work]]</li>
 
</ul>
- Then we tried the microphone but its a carbon mic and it didnt work. so we atttached a battery and hoped. didnt work.
 
- We took apart wired headphones that had mic in them to see if we could use the mic from it rather than the carbon mic in the telephone.-> didnt work, headphone cable is TRRS not TRS:
 
<img src="https://wiringall.com/image/trrs-to-trs-wiring-diagram-7.jpg" width="300px">
 
spent a day trying to wire up TRRS to an audio cable, turns out the audio jack was the wrong kind.


then wired it directly to a TRS jack, worked!!!!!!!!!!!!!
- We took the phone apart and got the speaker to work by connecting the blue and red cables from the phone out to the audio jack to the soundcard to the computer. played show me the body, was good. <br>
- Then we tried the microphone but its a carbon mic and it didnt work. so we attached a battery and hoped. didnt work. <br>
- We took apart wired headphones that had mic in them to see if we could use the mic from it rather than the carbon mic in the telephone.-> didnt work, headphone cable is TRRS not TRS: <br>


then cable managed, looks beautiful now. now we have working speakers and working mic.
[[File:Trrs-to-trs-wiring-diagram-7.jpg|300px|frameless]]


<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwww.soundguys.com%2Fwp-content%2Fuploads%2F2023%2F12%2Fapple-earpods-controls.jpg&f=1&nofb=1&ipt=26271a906fa38f69409204c5250587a2f7416bd1b748200d8d1faf7b52b053f2&ipo=images" width="300px">
- Spent a day trying to wire up TRRS to an audio cable, turns out the audio jack was the wrong kind. <br>
- Then wired it directly to a TRS jack, worked!!!!!!!!!!!!! <br>
- Then cable managed, looks beautiful now. now we have working speakers and working mic. <br>


'''This is how you could make it work too (Schema 1)'''
[[File:Apple-earpods-controls-1461747330.jpg|300px|frameless]]


'''This is how you could make it work too (Schema 1)''' <br>
From the headphones you need to...
From the headphones you need to...
 
:* Connect the Blue (Ground) to the Sleeve of the TRS jack
Connect th Blue (Ground) to the Sleeve of the TRS jack
:* Connect the Red (mic) to Pin (Ring) 1 or 2 of the TRS jack
 
Connect the Red (mic) to Pin (Ring) 1 or 2 of the TRS jack
 
MAKE SURE THE HEADPHONES CONNECTION IS CLOSED!  
MAKE SURE THE HEADPHONES CONNECTION IS CLOSED!  
[[File:Signal-2024-11-07-192445.jpg|thumb|The wiring used]]
[[File:Signal-2024-11-07-192445.jpg|thumb|The wiring used]]
[[File:Sketch wiringHeadphones.jpg|thumb|sketch of the wiring of the handset connection (Schema 1)]]
[[File:Sketch wiringHeadphones.jpg|thumb|sketch of the wiring of the handset connection (Schema 1)]]


'''<u>Next Steps:</u>'''
'''<u>Next Steps:</u>''' <br>
 
- We need to work out how to read the keypad input on the raspberrypi. Mark Powers has a snippet of code that supposedly works with this: https://marks.kitchen/blog/rotary_phone_running_linux/ <br>
We need to work out how to read the keypad input on the raspberrypi. Mark Powers has a snippet of code that supposedly works with this: https://marks.kitchen/blog/rotary_phone_running_linux/
- To test our phone we used this GitHub project: https://github.com/ralphcrutzen/PTT-Tafeltjes-Telefoon?tab=readme-ov-file. <br>
 
: > This project turns the phone into a math game  where a child asks you a times table question and you are supposed to give the correct answer using the rotary keypad. When you dial the answer the py code reads it as 2 separate entires and gives you a ''Goed zo!'' if you gave the correct answer. <br>
To test our phone we used this GitHub project: https://github.com/ralphcrutzen/PTT-Tafeltjes-Telefoon?tab=readme-ov-file. > This project turns the phone into a math game  where a child asks you a times table question and you are supposed to give the correct answer using the rotary keypad. When you dial the answer the py code reads it as 2 separate entires and gives you a ''Goed zo!'' if you gave the correct answer.
- Fred is translating the code to eng. He also thinks I can't do times tables. <br>
 
- Set up the raspberrypi, named it telephone.(tut here: https://nematicslab.com/how-to-enable-ssh-without-using-a-monitor/) <br>
Fred is translating the code to eng. He also thinks I can't do times tables.  
- Fred made me a user(Sevgi) as well and we tested the connections first, adjusted the code accordingly. Fred tested the connections like this (this is the final working version): <br>
 
import RPi.GPIO as GPIO
Set up the raspberrypi, named it telephone.(tut here:https://nematicslab.com/how-to-enable-ssh-without-using-a-monitor/)  
 
GPIO.setmode(GPIO.BCM)
Fred made me a user(Sevgi) as well and we tested the connections first, adjusted the code accordingly. Fred tested the connections like this (this is the final working version):<syntaxhighlight lang="py">
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_UP)
import RPi.GPIO as GPIO
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)
 
GPIO.setup(25, GPIO.IN, pull_up_down = GPIO.PUD_UP)
 
GPIO.setmode(GPIO.BCM)
while True:
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(25, GPIO.IN, pull_up_down = GPIO.PUD_UP)
 
while True:
       
         print('-')
         print('-')
         if GPIO.input(23):
         if GPIO.input(23):
Line 87: Line 64:
         if GPIO.input(24):
         if GPIO.input(24):
                 print('24')
                 print('24')
</syntaxhighlight>Here is how we set up the wires and the raspberry pi:
Here is how we set up the wires and the raspberry pi:
 
[[File:Wire Sketch rbpi.png|frameless|469x469px]]
[[File:Wire Sketch rbpi.png|frameless|469x469px]]
This wiring worked for us at first, but then we had to put the ground cables in different Rbpi GND's for it to work again.
This wiring worked for us at first, but then we had to put the ground cables in different Rbpi GND's for it to work again.


Here is the eng version of the dutch code: https://pzwiki.wdka.nl/mediadesign/User:Wordfa/oldphonehack/PTT_Tafeltjes_Telefoon
Here is the eng version of the dutch code: https://pzwiki.wdka.nl/mediadesign/User:Wordfa/oldphonehack/PTT_Tafeltjes_Telefoon


Fred wrote down a test code which we now lost... <syntaxhighlight lang="py">
We now reverted back to writing the code Ralph Crutzen's way, using pygame. We pulled this code from: https://github.com/pygame/pygame/blob/main/examples/audiocapture.py <br>
Last login: Mon Nov 11 18:05:41 on ttys000
designworm@Designs-MBP ~ % ssh sevgi@192.168.1.113
sevgi@192.168.1.113's password:  
Linux telephone 6.6.51+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.51-1+rpt3 (2024-10-08) aarch64


The programs included with the Debian GNU/Linux system are free software;
""" pygame.examples.audiocapture
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
A pygame 2 experiment.
 
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
* record sound from a microphone
permitted by applicable law.
* play back the recorded sound
Last login: Mon Nov 11 17:49:30 2024 from 192.168.1.158
"""
sevgi@telephone:~ $ exit
import pygame as pg
logout
import time
Connection to 192.168.1.113 closed.
import wave
designworm@Designs-MBP ~ % ssh wordie@192.168.1.113
wordie@192.168.1.113's password:
from pygame._sdl2 import (
Permission denied, please try again.
    get_audio_device_names,
wordie@192.168.1.113's password:
    AudioDevice,
Linux telephone 6.6.51+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.51-1+rpt3 (2024-10-08) aarch64
    AUDIO_F32,
 
    AUDIO_ALLOW_FORMAT_CHANGE,
The programs included with the Debian GNU/Linux system are free software;
)
the exact distribution terms for each program are described in the
from pygame._sdl2.mixer import set_post_mix
individual files in /usr/share/doc/*/copyright.
# sound length (seconds, a float)
 
SOUNDLEN = 2.0
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
# sound frequency (in Herz: the number of vibrations per second)
permitted by applicable law.
SOUNDFREQ = 1000
Last login: Mon Nov 11 17:46:47 2024
# maximal amplitude
wordie@telephone:~ $ cd
MAXAMP = 32767 / 2
wordie@telephone:~ $ ls
# sampling frequency (in Herz: the number of samples per second)
Bookshelf Documents Music    Public    Videos
SAMPLINGFREQ = 44100
Desktop    Downloads Pictures Templates telephone
# the number of channels (1=mono, 2=stereo)
wordie@telephone:~ $ cd telephone
NCHANNELS = 2
wordie@telephone:~/telephone $ ls
"08 I DON'T WANT TO FALL IN LOVE AGAIN.wav"   markOne.py  rotary_pi
pg.mixer.pre_init(44100, 32, 2, 512)
'Sunday Morning Maroon 5.mp3'                markTwo.py  test.py
pg.init()
wordie@telephone:~/telephone $ nano test.py
wordie@telephone:~/telephone $ nano test.py
# init_subsystem(INIT_AUDIO)
wordie@telephone:~/telephone $ ls
names = get_audio_device_names(True)
"08 I DON'T WANT TO FALL IN LOVE AGAIN.wav"   capture.py  markTwo.py  test.py
  print(names)
'Sunday Morning Maroon 5.mp3'                markOne.py  rotary_pi
  sounds = []
wordie@telephone:~/telephone $ nano capture.py
  sound_chunks = []
wordie@telephone:~/telephone $ nano test.py
   
wordie@telephone:~/telephone $ nano capture.py
  def callback(audiodevice, audiomemoryview):
 
    """This is called in the sound thread.
  GNU nano 7.2                      capture.py                               
    Note, that the frequency and such you request may not be what you get.
    """
    # print(type(audiomemoryview), len(audiomemoryview))
    # print(audiodevice)
    sound_chunks.append(bytes(audiomemoryview))
def postmix_callback(postmix, audiomemoryview):
    """This is called in the sound thread.
    At the end of mixing we get this data.
    """
    print(type(audiomemoryview), len(audiomemoryview))
    print(postmix)
set_post_mix(postmix_callback)
audio = AudioDevice(
    devicename=names[0],
    iscapture=True,
     frequency=44100,
     frequency=44100,
     audioformat=AUDIO_F32,
     audioformat=AUDIO_F32,
Line 148: Line 138:
     allowed_changes=AUDIO_ALLOW_FORMAT_CHANGE,
     allowed_changes=AUDIO_ALLOW_FORMAT_CHANGE,
     callback=callback,
     callback=callback,
)
)
# start recording.
# start recording.
audio.pause(0)
audio.pause(0)
print(audio)
print(f"recording with '{names[0]}'")
time.sleep(2)
print("Turning data into a pg.mixer.Sound")
sound = pg.mixer.Sound(buffer=b"".join(sound_chunks))
snd = pg.mixer.Sound(sound)
# open new wave file
sfile = wave.open('pure_tone.wav', 'w')
# set the parameters
sfile.setnchannels(NCHANNELS)
# write raw PyGame sound buffer to wave file
sfile.writeframesraw(snd.get_raw())
# close file
sfile.close()
print("playing back recorded sound")
sound.play()
time.sleep(2)
pg.quit()
 
This didn't really work, just worked for us to record the sound and play it back on the handset.
 
We gave up on pygame and used pyaudio. Fred found this snippet of code which we will try to translate into our test.py: <br>
import RPi.GPIO as gpio
from recorder import Recorder
gpio.setmode(gpio.BCM) 
class ButtonRecorder(object):
    def __init__(self, filename):
        self.filename = filename
        gpio.setup(23, gpio.IN, pull_up_down=gpio.PUD_UP)
        self.rec = Recorder(channels=2)
    def start(self):
        gpio.add_event_detect(23, gpio.FALLING, callback=self.falling, bouncetime=10)
    def rising(self, channel):
        gpio.remove_event_detect(23)
        print 'Button up'
        gpio.add_event_detect(23, gpio.FALLING, callback=self.falling, bouncetime=10)
        self.recfile.stop_recording()
        self.recfile.close()
    def falling(self, channel):
        gpio.remove_event_detect(23)
        print 'Button down'
        gpio.add_event_detect(23, gpio.RISING, callback=self.rising, bouncetime=10)
        self.recfile = self.rec.open(self.filename, 'wb')   
        self.recfile.start_recording()
rec = ButtonRecorder('nonblocking.wav')
rec.start()
try:
    raw_input()
except KeyboardInterrupt:
    pass
gpio.cleanup()
 
<div class="invisible">
We managed to get a recording with this code
{{Audio|mp3=https://pzwiki.wdka.nl/mw-mediadesign/images/a/ad/Output-11.11.2024.mp3|style=width:100%}}
</div>
We made a first recording with this. (We were discussing if having a limited time to record is okay instead of hanging the phone to stop recording and its a second of that convo) <br>
We combined these 2 snippets together but had errors, we had to install a bunch of audio related python scripts and Joseph told us to download sox (in his words: Swiss army knife Audio python scripts): <code>sudo apt install sox</code>


print(audio)
We had to do some troubleshooting for sox because it also didn't work perfectly of course.


print(f"recording with '{names[0]}'")
==== To do list from 13/11/2024 on: ====
time.sleep(2)
* discuss the intro in detail : maybe a connecting sound(?) at first, then hold music, then intro, then press 1 for: etc, beep sound before the recording, etc. , before the recording: disclaimer,
* decide whether we have different audios for each pickup (DONE)
* what is the detailed version of the 'annoying' bureaucratic protocol? make it a detailed question.
* discuss decor after the giveaway shop visit (DONE) [[File:Output-11.11.2024.mp3|thumb|Our first recording]]
* collect forms / print forms 
* (eventually) make the pi go into the phone and fix the wiring (take everything out, solder the wires, ) (DONE)      


==== 13/11/2024 ====
We went to the weggeefwinkel to grab some office related decor. Which was amazing, we got a desk lamp, plastic transparent folder, an old picture of some business people and a frame to go with it and a briefcase to put them all in.   


print("Turning data into a pg.mixer.Sound")
Today everything went wrong... We discovered that the little metal tabs need to be warmed up by the solder machine and then get a bit of lead on them to make them work. Joseph told us we need to let the machine warm up the tabs until they are both ~325 °C, then let some solder into the tab. After the warm up, the solder should stick to the tab. Martina tried really hard and managed to connect 3 wires (without knowing any of this), Fred and Sevgi couldn't manage the other and gave up on that. (Martina said it was easy when She did it) We wired everything with different ways and took the case off of the pi to make it fit inside the telephone.   


sound = pg.mixer.Sound(buffer=b"".join(sound_chunks))
We took out the bells to be used in the jam session.  
snd = pg.mixer.Sound(sound)


# open new wave file
Fred cleaned the rotary part and the spiral came out which took him forever to put back. Eventually he figured out it is easier to attach the inner bit and then coil the rest of the spiral inside. Now the rotary is clean and it works smoother.                               
sfile = wave.open('pure_tone.wav', 'w')


# set the parameters
After putting everything back together, there seems to be a tone of connection issues. Audio seems to being played lower then expected but Maroon 5 still sounded good. Fred stayed behind and managed to fix it by uninstalling and reinstalling pulseaudio and playing around with Sox.                               
sfile.setnchannels(NCHANNELS)


# write raw PyGame sound buffer to wave file
We still have rest of the to-do list to go through                               
sfile.writeframesraw(snd.get_raw())


# close file
Everyone hated today 
sfile.close()


print("playing back recorded sound")
==== 14/11/2024 ====
sound.play()
''Martina typing:'' <br>
time.sleep(2)
Fred added a function to clean up the recordings and make them louder. He also tidied up the code, added some beep tones when numbers are dialed in. In the code, he also made a function to loop through all the recordings randomly. <br>
pg.quit()
Code for Today -> [[User:Wordfa/oldphonehack/code14nov]]
[[File:Press 1 for- Flowchart.png|alt=Press 1 for: Flowchart|thumb|450x450px|Press 1 for: Flowchart]]


Fred and I discussed the next steps to be done for the weekend: <br>
I will work on the script and the forms that will be placed on the text. The inspiration is to make them look like survey forms, maybe participants can also interact with these forms. <br>
Fred also made this flowchart of how the call can follow different outcomes. <br>                                                         
At the end of the day, Fred and I tried to close up the telephone with the pi and cables inside, but unfortunately it does not fit.... we re-wired some of the cables to make the pi fit on the outside of the telephone. We will do the rest on Monday as we didn't have enough soldering wire and were very tired </3                                                                                                                                   


^G Help      ^O Write Out ^W Where Is  ^K Cut      ^T Execute  ^C Location
Figma flowchart with draft text: https://www.figma.com/board/aKK1GVkBnmIyScXWcyUmGP/telephone-flowchart?node-id=0-1&node-type=canvas&t=T2I1UidcYxM7jHld-0                                                                                                                                   
^X Exit      ^R Read File ^\ Replace  ^U Paste    ^J Justify  ^/ Go To Line


</syntaxhighlight>
These are the tasks that we will work on Monday:                                                                 
* Re-wire the rest of the cables to make the pi fit on the outside of the telephone. (DONE)
* Read through the draft script together and arrange it. (DONE)
* Record the script audios and upload everything into the code. (DONE)
* Make sure that everything sounds good on the telephone. (DONE)
* Check in with Worm to see if they have an office table? (will be done wednesday)
* Print forms (with HR printers or publication studio?) (DONE)
* Pack up all the decor, equipment, etc.. (DONE)
* Check ways to reduce noise (DONE)
* Record a few complaints for option 2 / maybe ask the class on Zulip to record some complaints


== Refs and resources ==
==== 18/11/2024 ====
'''Microphone from handset'''
''Martina typing:'' <br>
During this session, we continued the rest of the soldering to make the pi rest outside. All went well but we did have some sound issues, but all got fixed when Fred adjusted the volume settings. <br>
Sevgi, Fred and I also went through the script together (spoken script for telephone). Later on, I recorded the audio so Fred would be able to put it into the code. We also added a 'secret' feature where you can dial in 9 to listen to the last recording. This is mainly for us to know that the telephone is working correctly.


https://www.youtube.com/watch?v=rIkIkbOw3OQ&t
==== 19/11/2024 ====
''Martina typing:'' <br>
One day left!!!! <br>
We started straight with working on the final details. Sevgi and Fred dressed Sassie back up and she looks gorgeous with her shell on! I worked on printing the survey forms on the paper we found from scrap. Feline kindly helped me navigate the HR printers and we have beautiful forms, they will be placed in the white folder on the office desk installation. <br>
I packed up all our office decor to be ready for tomorrow while Fred cleans up the code. He also made a secret new function: if you press 0, you hear a lovely tune.  


'''Rotary Pi'''
<div class="invisible">


* Really good write up with code:
== Post Performance ==
* https://marks.kitchen/blog/rotary_phone_running_linux/
</div>
* Linking Video
== Refs and resources ==
* https://www.youtube.com/watch?v=M4eCrctDMEc
'''Microphone from handset''' <br>
https://www.youtube.com/watch?v=rIkIkbOw3OQ&t


'''Lofi Mic'''
'''Rotary Pi''' <br>
* Really good write up with code: https://marks.kitchen/blog/rotary_phone_running_linux/
* Linking Video https://www.youtube.com/watch?v=M4eCrctDMEc


'''Lofi Mic''' <br>
https://www.youtube.com/watch?v=7gorBkdk8zY
https://www.youtube.com/watch?v=7gorBkdk8zY


'''Schematic (v scary) '''
'''Schematic (v scary) ''' <br>
 
https://easyeda.com/editor#id=7d0350ec43844219912695cec1a0e156
https://easyeda.com/editor#id=7d0350ec43844219912695cec1a0e156


'''Rotary MP3 Player'''
'''Rotary MP3 Player''' <br>
 
https://www.whizzbizz.com/en/gpo746-t65-rotary-dial-phone-mp3-wav-player
https://www.whizzbizz.com/en/gpo746-t65-rotary-dial-phone-mp3-wav-player


'''Info on the T65'''
'''Info on the T65''' <br>
 
https://www.cryptomuseum.com/phone/t65/index.htm (there is a wire list here as well)
https://www.cryptomuseum.com/phone/t65/index.htm<nowiki/>(there is a wire list here as well)[[File:Screenshot 2024-11-07 at 21.40.36.png|thumb|possible way to wire up carbon microphone]]
[[File:Screenshot 2024-11-07 at 21.40.36.png|thumb|possible way to wire up carbon microphone]]
 
'''Carbon Mic'''
 
https://www.youtube.com/watch?v=cwPPoVvljOw


'''Carbon Mic''' <br>
https://www.youtube.com/watch?v=cwPPoVvljOw <br>
https://www.youtube.com/watch?v=pb-Lu2kzKYc&t=221s
https://www.youtube.com/watch?v=pb-Lu2kzKYc&t=221s


'''Dutch guide on rotary dail'''
'''Dutch guide on rotary dail''' <br>
https://github.com/ralphcrutzen/PTT-Tafeltjes-Telefoon?tab=readme-ov-file


https://github.com/ralphcrutzen/PTT-Tafeltjes-Telefoon?tab=readme-ov-file
'''Guide on getting Keypad Working (Matrix should be tried)''' <br>
https://web.archive.org/web/20130919160654/http://www.keesvanweert.nl/blog/?p=1


'''Guide on getting Keypad Working (Matrix should be tried)'''
'''Reducing Noise on Mic''' <br>
https://forums.raspberrypi.com/viewtopic.php?t=312184 <br>
https://raspberrypi.stackexchange.com/questions/79994/high-background-noise-with-usb-microphone


https://web.archive.org/web/20130919160654/http://www.keesvanweert.nl/blog/?p=1
=== Weird Stuff ===
=== Weird Stuff ===
how does a carbon mic work
how does a carbon mic work <br>
 
https://wonderfoon.jimdosite.com/
https://wonderfoon.jimdosite.com/
https://www.youtube.com/@ruudshangout/search?query=t65
https://www.youtube.com/@ruudshangout/search?query=t65


=== Event Rider: ===
=== Event Rider: ===
 
'''Items Needs'''
===== Items Needs =====
* Table [ ] - from XPUb studio
 
* Chair [ ] - WORM
* Table [ ]
* Phone [x]  
* Chair [ ]
* Lamp [ ] - Fred has a lamp
* Phone [x]
* Calendar [ ]  
* Lamp [ ]
* Calendar [ ]
* Forms on table? [ ]  
* Forms on table? [ ]  
* Assorted Desk Items [ ]  
* Assorted Desk Items [ ] - from giveaway shop - bring the cups from studio


'''Space Needs'''
'''Space Needs'''
* 2m x 2m (UBIK)
* 2m x 2m (UBIK)
* Power (UBIK)
* Power (UBIK)
Line 253: Line 336:


'''Time Needs'''
'''Time Needs'''
* Async/ All day


* Async/ All day
== Documentation from SI #25 ==
* In this section, we compiled a bit of documentation of the event set up and the BRC document. The event was a success, people participated and interacted with our installation and enjoyed tuning into the call system. We did get feedback that the voice was a bit too low, given that the event was packed and there was a lot of chatter in the background.
* The BRC report is a collection of the transcripts from each recorded feedback. Each of them has been censored and we also included diagrams, bar graphs and visualisations to give a more statistical feel to our final compilation.
<ul class="gallery">
<li style="display: inline-block;">[[File:BRC.jpg|thumb|150px|The BRC station in use at UBIK.]]</li>
<li style="display: inline-block;">[[File:BRC2.jpg|thumb|150px|BRC set up on install day.]]</li>
<li style="display: inline-block;">[[File:Brc3.jpg|thumb|150px|Sassie the telephone.]]</li>
<li style="display: inline-block;">[[File:Brc4.jpg|thumb|150px|BRC report published after the SI event.]]</li>
<li style="display: inline-block;">[[File:Brc5.jpg|thumb|150px|BRC report.]]</li>
<li style="display: inline-block;">[[File:Brc6.jpg|thumb|150px|Introduction text.]]</li>
<li style="display: inline-block;">[[File:Brc7.jpg|thumb|150px]]</li>
<li style="display: inline-block;">[[File:Brc8.jpg|thumb|150px]]</li>
<li style="display: inline-block;">[[File:Brc9.jpg|thumb|150px|Scans of the surveys participants filled in after testing out "Press 1 for".]]</li>
</ul>

Latest revision as of 16:36, 14 July 2025

Press #1 For:

<img src="Old_phonebitmap.png" style="transform: rotate(90deg); width: 59.5mm !important;" class="press1for">

Description

From getting your BSN to installing internet in your new home to renting a car, rigid mazes of bureaucratic systems hold us all hostage. In the spirit of collective catharsis 'Press One For' invites you to share and listen to stories of how these systems frustrated you, or how you frustrated them.

T65 Rotary Phone bought by Sevgi n' Fred

Cookbook

Parts Required

Things we done

- We got one phone from ScrapXL Rotterdam and one from Marktplaats. The first one was a T65

- We took the phone apart and got the speaker to work by connecting the blue and red cables from the phone out to the audio jack to the soundcard to the computer. played show me the body, was good.
- Then we tried the microphone but its a carbon mic and it didnt work. so we attached a battery and hoped. didnt work.
- We took apart wired headphones that had mic in them to see if we could use the mic from it rather than the carbon mic in the telephone.-> didnt work, headphone cable is TRRS not TRS:

Trrs-to-trs-wiring-diagram-7.jpg

- Spent a day trying to wire up TRRS to an audio cable, turns out the audio jack was the wrong kind.
- Then wired it directly to a TRS jack, worked!!!!!!!!!!!!!
- Then cable managed, looks beautiful now. now we have working speakers and working mic.

Apple-earpods-controls-1461747330.jpg

This is how you could make it work too (Schema 1)
From the headphones you need to...

  • Connect the Blue (Ground) to the Sleeve of the TRS jack
  • Connect the Red (mic) to Pin (Ring) 1 or 2 of the TRS jack

MAKE SURE THE HEADPHONES CONNECTION IS CLOSED!

The wiring used
sketch of the wiring of the handset connection (Schema 1)

Next Steps:
- We need to work out how to read the keypad input on the raspberrypi. Mark Powers has a snippet of code that supposedly works with this: https://marks.kitchen/blog/rotary_phone_running_linux/
- To test our phone we used this GitHub project: https://github.com/ralphcrutzen/PTT-Tafeltjes-Telefoon?tab=readme-ov-file.

> This project turns the phone into a math game where a child asks you a times table question and you are supposed to give the correct answer using the rotary keypad. When you dial the answer the py code reads it as 2 separate entires and gives you a Goed zo! if you gave the correct answer.

- Fred is translating the code to eng. He also thinks I can't do times tables.
- Set up the raspberrypi, named it telephone.(tut here: https://nematicslab.com/how-to-enable-ssh-without-using-a-monitor/)
- Fred made me a user(Sevgi) as well and we tested the connections first, adjusted the code accordingly. Fred tested the connections like this (this is the final working version):

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)
GPIO.setup(25, GPIO.IN, pull_up_down = GPIO.PUD_UP)

while True:
       print('-')
       if GPIO.input(23):
               print('23')
       if GPIO.input(25):
               print('25')
       if GPIO.input(24):
               print('24')

Here is how we set up the wires and the raspberry pi: Wire Sketch rbpi.png This wiring worked for us at first, but then we had to put the ground cables in different Rbpi GND's for it to work again.

Here is the eng version of the dutch code: https://pzwiki.wdka.nl/mediadesign/User:Wordfa/oldphonehack/PTT_Tafeltjes_Telefoon

We now reverted back to writing the code Ralph Crutzen's way, using pygame. We pulled this code from: https://github.com/pygame/pygame/blob/main/examples/audiocapture.py

""" pygame.examples.audiocapture

A pygame 2 experiment.

* record sound from a microphone
* play back the recorded sound
"""
import pygame as pg
import time
import wave

from pygame._sdl2 import (
   get_audio_device_names,
   AudioDevice,
   AUDIO_F32,
   AUDIO_ALLOW_FORMAT_CHANGE,
)
from pygame._sdl2.mixer import set_post_mix
# sound length (seconds, a float)
SOUNDLEN = 2.0
# sound frequency (in Herz: the number of vibrations per second)
SOUNDFREQ = 1000
# maximal amplitude
MAXAMP = 32767 / 2
# sampling frequency (in Herz: the number of samples per second)
SAMPLINGFREQ = 44100
# the number of channels (1=mono, 2=stereo)
NCHANNELS = 2

pg.mixer.pre_init(44100, 32, 2, 512)
pg.init()

# init_subsystem(INIT_AUDIO)
names = get_audio_device_names(True)
print(names)
sounds = []
sound_chunks = []

def callback(audiodevice, audiomemoryview):
   """This is called in the sound thread.

   Note, that the frequency and such you request may not be what you get.
   """
   # print(type(audiomemoryview), len(audiomemoryview))
   # print(audiodevice)
   sound_chunks.append(bytes(audiomemoryview))

def postmix_callback(postmix, audiomemoryview):
   """This is called in the sound thread.

   At the end of mixing we get this data.
   """
   print(type(audiomemoryview), len(audiomemoryview))
   print(postmix)

set_post_mix(postmix_callback)

audio = AudioDevice(
   devicename=names[0],
   iscapture=True,
   frequency=44100,
   audioformat=AUDIO_F32,
   numchannels=2,
   chunksize=512,
   allowed_changes=AUDIO_ALLOW_FORMAT_CHANGE,
   callback=callback,
)
# start recording.
audio.pause(0)
print(audio)

print(f"recording with '{names[0]}'")
time.sleep(2)

print("Turning data into a pg.mixer.Sound")

sound = pg.mixer.Sound(buffer=b"".join(sound_chunks))
snd = pg.mixer.Sound(sound)

# open new wave file
sfile = wave.open('pure_tone.wav', 'w')

# set the parameters
sfile.setnchannels(NCHANNELS)

# write raw PyGame sound buffer to wave file
sfile.writeframesraw(snd.get_raw())

# close file
sfile.close()

print("playing back recorded sound")
sound.play()
time.sleep(2)
pg.quit()

This didn't really work, just worked for us to record the sound and play it back on the handset.

We gave up on pygame and used pyaudio. Fred found this snippet of code which we will try to translate into our test.py:

import RPi.GPIO as gpio 
from recorder import Recorder 
gpio.setmode(gpio.BCM)  

class ButtonRecorder(object): 
   def __init__(self, filename): 
       self.filename = filename 
       gpio.setup(23, gpio.IN, pull_up_down=gpio.PUD_UP) 
       self.rec = Recorder(channels=2) 

   def start(self): 
       gpio.add_event_detect(23, gpio.FALLING, callback=self.falling, bouncetime=10) 

   def rising(self, channel): 
       gpio.remove_event_detect(23) 
       print 'Button up' 
       gpio.add_event_detect(23, gpio.FALLING, callback=self.falling, bouncetime=10) 
       self.recfile.stop_recording() 
       self.recfile.close() 

   def falling(self, channel): 
       gpio.remove_event_detect(23) 
       print 'Button down' 
       gpio.add_event_detect(23, gpio.RISING, callback=self.rising, bouncetime=10) 
       self.recfile = self.rec.open(self.filename, 'wb')    
       self.recfile.start_recording() 

rec = ButtonRecorder('nonblocking.wav')
rec.start() 

try: 
   raw_input() 

except KeyboardInterrupt: 
   pass 

gpio.cleanup()

We made a first recording with this. (We were discussing if having a limited time to record is okay instead of hanging the phone to stop recording and its a second of that convo)
We combined these 2 snippets together but had errors, we had to install a bunch of audio related python scripts and Joseph told us to download sox (in his words: Swiss army knife Audio python scripts): sudo apt install sox

We had to do some troubleshooting for sox because it also didn't work perfectly of course.

To do list from 13/11/2024 on:

  • discuss the intro in detail : maybe a connecting sound(?) at first, then hold music, then intro, then press 1 for: etc, beep sound before the recording, etc. , before the recording: disclaimer,
  • decide whether we have different audios for each pickup (DONE)
  • what is the detailed version of the 'annoying' bureaucratic protocol? make it a detailed question.
  • discuss decor after the giveaway shop visit (DONE) File:Output-11.11.2024.mp3
  • collect forms / print forms
  • (eventually) make the pi go into the phone and fix the wiring (take everything out, solder the wires, ) (DONE)

13/11/2024

We went to the weggeefwinkel to grab some office related decor. Which was amazing, we got a desk lamp, plastic transparent folder, an old picture of some business people and a frame to go with it and a briefcase to put them all in.

Today everything went wrong... We discovered that the little metal tabs need to be warmed up by the solder machine and then get a bit of lead on them to make them work. Joseph told us we need to let the machine warm up the tabs until they are both ~325 °C, then let some solder into the tab. After the warm up, the solder should stick to the tab. Martina tried really hard and managed to connect 3 wires (without knowing any of this), Fred and Sevgi couldn't manage the other and gave up on that. (Martina said it was easy when She did it) We wired everything with different ways and took the case off of the pi to make it fit inside the telephone.

We took out the bells to be used in the jam session.

Fred cleaned the rotary part and the spiral came out which took him forever to put back. Eventually he figured out it is easier to attach the inner bit and then coil the rest of the spiral inside. Now the rotary is clean and it works smoother.

After putting everything back together, there seems to be a tone of connection issues. Audio seems to being played lower then expected but Maroon 5 still sounded good. Fred stayed behind and managed to fix it by uninstalling and reinstalling pulseaudio and playing around with Sox.

We still have rest of the to-do list to go through

Everyone hated today

14/11/2024

Martina typing:
Fred added a function to clean up the recordings and make them louder. He also tidied up the code, added some beep tones when numbers are dialed in. In the code, he also made a function to loop through all the recordings randomly.
Code for Today -> User:Wordfa/oldphonehack/code14nov

Press 1 for: Flowchart
Press 1 for: Flowchart

Fred and I discussed the next steps to be done for the weekend:
I will work on the script and the forms that will be placed on the text. The inspiration is to make them look like survey forms, maybe participants can also interact with these forms.
Fred also made this flowchart of how the call can follow different outcomes.
At the end of the day, Fred and I tried to close up the telephone with the pi and cables inside, but unfortunately it does not fit.... we re-wired some of the cables to make the pi fit on the outside of the telephone. We will do the rest on Monday as we didn't have enough soldering wire and were very tired </3

Figma flowchart with draft text: https://www.figma.com/board/aKK1GVkBnmIyScXWcyUmGP/telephone-flowchart?node-id=0-1&node-type=canvas&t=T2I1UidcYxM7jHld-0

These are the tasks that we will work on Monday:

  • Re-wire the rest of the cables to make the pi fit on the outside of the telephone. (DONE)
  • Read through the draft script together and arrange it. (DONE)
  • Record the script audios and upload everything into the code. (DONE)
  • Make sure that everything sounds good on the telephone. (DONE)
  • Check in with Worm to see if they have an office table? (will be done wednesday)
  • Print forms (with HR printers or publication studio?) (DONE)
  • Pack up all the decor, equipment, etc.. (DONE)
  • Check ways to reduce noise (DONE)
  • Record a few complaints for option 2 / maybe ask the class on Zulip to record some complaints

18/11/2024

Martina typing:
During this session, we continued the rest of the soldering to make the pi rest outside. All went well but we did have some sound issues, but all got fixed when Fred adjusted the volume settings.
Sevgi, Fred and I also went through the script together (spoken script for telephone). Later on, I recorded the audio so Fred would be able to put it into the code. We also added a 'secret' feature where you can dial in 9 to listen to the last recording. This is mainly for us to know that the telephone is working correctly.

19/11/2024

Martina typing:
One day left!!!!
We started straight with working on the final details. Sevgi and Fred dressed Sassie back up and she looks gorgeous with her shell on! I worked on printing the survey forms on the paper we found from scrap. Feline kindly helped me navigate the HR printers and we have beautiful forms, they will be placed in the white folder on the office desk installation.
I packed up all our office decor to be ready for tomorrow while Fred cleans up the code. He also made a secret new function: if you press 0, you hear a lovely tune.

Refs and resources

Microphone from handset
https://www.youtube.com/watch?v=rIkIkbOw3OQ&t

Rotary Pi

Lofi Mic
https://www.youtube.com/watch?v=7gorBkdk8zY

Schematic (v scary)
https://easyeda.com/editor#id=7d0350ec43844219912695cec1a0e156

Rotary MP3 Player
https://www.whizzbizz.com/en/gpo746-t65-rotary-dial-phone-mp3-wav-player

Info on the T65
https://www.cryptomuseum.com/phone/t65/index.htm (there is a wire list here as well)

possible way to wire up carbon microphone

Carbon Mic
https://www.youtube.com/watch?v=cwPPoVvljOw
https://www.youtube.com/watch?v=pb-Lu2kzKYc&t=221s

Dutch guide on rotary dail
https://github.com/ralphcrutzen/PTT-Tafeltjes-Telefoon?tab=readme-ov-file

Guide on getting Keypad Working (Matrix should be tried)
https://web.archive.org/web/20130919160654/http://www.keesvanweert.nl/blog/?p=1

Reducing Noise on Mic
https://forums.raspberrypi.com/viewtopic.php?t=312184
https://raspberrypi.stackexchange.com/questions/79994/high-background-noise-with-usb-microphone

Weird Stuff

how does a carbon mic work
https://wonderfoon.jimdosite.com/ https://www.youtube.com/@ruudshangout/search?query=t65

Event Rider:

Items Needs

  • Table [ ] - from XPUb studio
  • Chair [ ] - WORM
  • Phone [x]
  • Lamp [ ] - Fred has a lamp
  • Calendar [ ]
  • Forms on table? [ ]
  • Assorted Desk Items [ ] - from giveaway shop - bring the cups from studio

Space Needs

  • 2m x 2m (UBIK)
  • Power (UBIK)
  • Low light preferred

Time Needs

  • Async/ All day

Documentation from SI #25

  • In this section, we compiled a bit of documentation of the event set up and the BRC document. The event was a success, people participated and interacted with our installation and enjoyed tuning into the call system. We did get feedback that the voice was a bit too low, given that the event was packed and there was a lot of chatter in the background.
  • The BRC report is a collection of the transcripts from each recorded feedback. Each of them has been censored and we also included diagrams, bar graphs and visualisations to give a more statistical feel to our final compilation.