Giter VIP home page Giter VIP logo

python3bluebox's Introduction

Python 3 Blue Box DTMF Tone Generator

Modernized python bluebox DTMF tone generator / dialer.

BlueBox Phreaking

How it works

In essence, this is a simple utility that creates dual tone multi-frequency sine waves (50/50 mixed, but that can easily be adjusted). What does this mean? Well you know the sounds that you hear if you have the touchpad tones turned on when you dial a number in your phone? That's what this is. It's able to generate the tones that correspond to the number and output it to an audio device or a python list (for example).

This tool has a CLI interface which allows you to send a sequence of codes via stdin, pipes, files, as an argument, or in an interactive mode.

Why?

Well, initially this was a fun little python 3 project from 2015, but I thought it would be nice to make it modern and extensible, essentially showcasing it as a framework, but this doesn't have to be limited to DTMF / MF, in theory with ease you could turn this into something that reads in code sequences (str) and outputs waves. Also due to issue #3 #3 it was clear that there were some bugs, so what better way to deal with it than adding tests and a way to decouple things!

Installation

PyPI

pip install mfbluebox

Development

git clone https://github.com/zeyus/Python3BlueBox.git
cd PythonBlueBox
pip install .

Requirements

  • Python 3 (tested on 3.9 - 3.11)

Usage

CLI

python -m bluebox -h

Output:

usage: __main__.py [-h] [-l LENGTH] [-p PAUSE] [-a AMPLITUDE] [-s SAMPLE_RATE] [-m MF] [-d] [-b BACKEND] [-r PAD_PAUSE_DURATION] [-f FILE] [-P PIPE] [-S] [-i] [-v] [sequence]

Generate tone sequences.

positional arguments:
  sequence              The sequence of tones to generate.

options:
  -h, --help            show this help message and exit
  -l LENGTH, --length LENGTH
                        The length of each tone in milliseconds.
  -p PAUSE, --pause PAUSE
                        The length of the pause between tones in milliseconds.
  -a AMPLITUDE, --amplitude AMPLITUDE
                        The combined amplitude of the waveforms.
  -s SAMPLE_RATE, --sample-rate SAMPLE_RATE
                        The sample rate of the waveforms.
  -m MF, --mf MF        The MF to use e.g. dtmf, mf.
  -d, --debug           Enable debug logging.
  -b BACKEND, --backend BACKEND
                        The backend to use for playing the waveforms.
  -r PAD_PAUSE_DURATION, --pad-pause-duration PAD_PAUSE_DURATION
                        The duration (ms) of the pause before/after sequence.
  -f FILE, --file FILE  The file to read the sequence from.
  -P PIPE, --pipe PIPE  Read the sequence from a pipe.
  -S, --stdin           Read the sequence from stdin.
  -i, --interactive     Enter interactive mode.
  -v, --version         show program's version number and exit

Examples

python -m bluebox -i
python -m bluebox 123456789

API

You mainly need an BaseMF subclass instance and a Sequencer instance.

from bluebox import DTMF
from bluebox.box import Sequencer

mf = DTMF()
seq = Sequencer(mf = mf)

seq('12345')

Development

Development of different MF implementations and audio backends is extremely easy now. Just create a new class that inherits from the MF class, and register it. Same thing for audio backends.

Currently there are two MF implementations (DTMF and MF), and two audio backends (PyAudio and Dummy).

python3bluebox's People

Contributors

dependabot[bot] avatar zeyus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

python3bluebox's Issues

Tones aren't right. Arithmetic is wrong.

Your DTMF tones don't sound like they're working right. The tones are going down in frequency as the numbers on the keypad get bigger. The sounds for the number #9 should be higher in frequency than #1, but your program is producing a lower frequency for #9 than for #1. Compare the sounds of the keypad on your cell phone to the sounds produced by your program to see what I mean.

It appears that you've gotten your arithmetic wrong. The arithmetic should look like this:

array.array('f', ((math.sin(2.0math.piitone[0]/sr) + math.sin(2.0math.piitone[1]/sr)) for i in range(int(sr*length)) )).tostring()

Running errors and what I think are logical errors

env:

  • Win10
  • Python 3.9.4 (tags/v3.9.4:1f2e308, Apr 4 2021, 13:27:16) [MSC v.1928 64 bit (AMD64)] on win32

The error is concentrated in this sentence:

 stream.write(array.array('f',
                             ((volume * math.sin(2.0 * math.pi * i * tone[0] / float(sr)) + volume * math.sin(2.0 * math.pi * i * tone[1] / float(sr)))
                              for i in range(sr*int(length)))).tostring())

Error1:

stream.write(array.array('f',
AttributeError: 'array.array' object has no attribute 'tostring'

Error2:
sr*int(length))
int(length) = int(0.25) = 0


After fixing the above 2 errors, you can dial normally through the phone handset

    commandDTMF = array.array('f',((volume * math.sin(2.0 * math.pi * i * tone[0] / float(sr)) + volume * math.sin(2.0 * math.pi * i * tone[1] / float(sr)))
                                for i in range(int(sr*length)))).tobytes()
    stream.write(commandDTMF)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.