Git Product home page Git Product logo

cw-trainer's Introduction

CW-Trainer

--------- IN PROCESS ------------

Android application for mastering CW skill. (for practices receiving morse code)

1. How I started that (Jan 18, 2018).

10 days ago I knew nothing about Android development and Java either. During those 10 days I completed couple courses about Java and Android which actually only scratch the surface. However, I decided that learn by doing a real project much better and efficient. I do not have much time to do this but I am going to spend my time on it after work and during weekends. During work days I am going to collect information and think over realization of it and during weekends try to implement that.

Do you belive that Morse is faster than Text Messaging? No, check it out - link.

What do I want to implement? Ok, I am going to organize that as a TODO list for myself.

TODO (in priority order)

  • Koch's methods - link
  • A Fully Automatic Morse Code Teaching Machine - link
  • Kind of Training machine to copy HAM calls. Idea from RufzXP.
  • Add a feature "the Pileup" into the last item.

It might look like I am going to reinvent wheels, but as I said before, this is just for practice and built up my skills.

2. Tone generation. (CwPlayer class)

Ok, first what should this class take as parameters on constractor.

  • Speed - as I know "PARIS" is frequently mentioned as the "standard word" for measuring translation speed. I also know that Speed (WPM) = 2.4 * (Dots per second). In code I am going use WPM - (speedWPM).
  • Frequency of the tone - kind of straightforward. (freqOfTone)
  • Ratios. Dash length | Dot length x 3 Pause between elements | Dot length Pause between characters | Dot length x 3 Pause between words | Dot length x 7 I want to be able change these ratios in settings.
  • Boolean flag that during generation tone we need to add white noise to signal.

About CW timing. link I break down a period of one dot into 5 units. So, one dash is going to exist 15 units.
Cw timing

I am going to generate 4 arrays of PCM samples for audio track and later push these arrays into audio buffer sequencely.

Number 2 is base array, "pure" sine with choosen frequency, I used it to generate number 1 and 3 by applying Blackman Harris Step Response. Number 4 is just array of 0.

During that I fell into the trap. Dependently on the speed of Morse code and frequency of tone I could get terrible sound. After thinking over this, I figured it out that this happens because the length of array number 2 (in time domain) is not a multiple of period of frequency of tone. And sine looked like below.

How I fixed this you can see in code.

3. Houston, we have a problem. (Jan 27, 2018).

Eventually I found that I know not enough about concurrency in Android. I stuck trying to let uiActivity know that some thread is finished. One of my friends gave me very nice and helpful book "Efficient Android Threading, asynchronous processing techniques for Android applications." by Anders Goransson. During this week I am going to read this book.

4. Refactoring CwPlayer. (Febn 2, 2018).

I have read a book which I mentioned before. This book has shed light on the problem. As a man who came from 'embedded word' I was wondering about stuff like mutex, semaphores, communication between Threads, data consistency in multy thread system, scheduling, and so on. I found handy realization AsynchThread, HandlerThread and other; learned about modificator 'synchronized' in Java, was surprised that Java has intrinsic methods of every object such as lock(), unlock(), wait() and notify().

Ok, lets implement something that I have read. Now my CwPlayer looks like this -> ''' java public class CwPlayer { Queue queue;

public void feed(byte charFeed) {
    queue.add(charFeed);
}

public CwPlayer() {
    queue = new LinkedList<>();
    ....
    startThread();
}

private class FeedBufferThread extends Thread {
    @Override
    public void run() {
        try {
            while (!isInterrupted()) {
                if (!queue.isEmpty()) {
                        playCW();
                    }
            }
        } catch ( Exception e) { e.printStackTrace(); }
    }

    private void playCW () {
        // remove character from Queue, decode and feed audio buffer.
    }
}


private void startThread() {
    feedBufferThread = new FeedBufferThread();
    feedBufferThread.start();
}

} ''' I do not like this approach.

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.