HobbyKing.com New Products Flash Sale
Reply
Thread Tools
Old Feb 25, 2013, 10:18 AM
---o-O-o---
blutoh's Avatar
United States, NJ, Livingston
Joined Mar 2012
1,604 Posts
Quote:
Originally Posted by Dutchraptor View Post
Blutoh,
I have a little code for you if you want to go the Arduino Route like I did. It's a sample with which I can read and extract which data is send and couple it to a function. We can combine this piece of code with your piece of code for the sound-part. The test is made with 1 potentiometer (10K) on analog 1 for reading/sending analog values. And I have on pin 5 and pin 6 a switch with a pull-down resistor (10K) to ground. The commands are added and given a groupnumber (in this case 2). After reading 1000 (for the extration of the analog value) or 2000 (for the digital value) are substracted. The digital values are then checked if a function is active or not.

Arduino and Python (in the shell, I still can't get it in the Terminal) are checked: No Firmate needed so I can read pins and send strings
Danny,

OK, I will go thru this in detail. I do want to use the Arduino, I just don't have one yet. I want to merge this into your arduino based radio system, to have a complete system with a complete feature set. I assume you will be creating a full build thread once you get things worked out, with all of the expansion boards etc.? Then I will be able to do testing and help with the development if you want.

Pete
blutoh is offline Find More Posts by blutoh
Reply With Quote
Sign up now
to remove ads between posts
Old Feb 25, 2013, 10:46 AM
Registered User
United States, PA
Joined Feb 2013
92 Posts
What do you use to edit a sound file? I have found some sounds by searching the net. Now I want to shorten them, both at the begining and end of the track, but not sure how to go about it.

HD
Heavy_Duty is offline Find More Posts by Heavy_Duty
Reply With Quote
Old Feb 25, 2013, 11:07 AM
---o-O-o---
blutoh's Avatar
United States, NJ, Livingston
Joined Mar 2012
1,604 Posts
Quote:
Originally Posted by Heavy_Duty View Post
What do you use to edit a sound file?.......
Hi HD,

I use Audacity. It's an Open Source visual audio editor. It works great, and it's free. It will easily do what you require and a whole lot more.

Pete
blutoh is offline Find More Posts by blutoh
Reply With Quote
Old Feb 25, 2013, 11:26 AM
Registered User
Dutchraptor's Avatar
The Netherlands, ZH, Hoogvliet
Joined Jul 2008
318 Posts
Quote:
Originally Posted by blutoh View Post
Danny,

I assume you will be creating a full build thread once you get things worked out, with all of the expansion boards etc.? Then I will be able to do testing and help with the development if you want.

Pete
All the help is welcome, that way we all benefit. There are still a few little thing on the Arduino side that I want to change. One is for example the channel readout. I still want to try to do that with PCF8574(A)P expanders instead of an extra Arduino. The transmitter board needs testing/building for a demo setup. After that the basic version is finished and I can work on some expansion units (I2C or Serial). Kinda cool: a Full Hybrid Arduino/Raspberry RC system. And best of all, cheaper then most 8 channel transmitters (and way more fun to make).

EDIT: finally found the way to make it work in the terminal: python ./name.py

Danny
Dutchraptor is online now Find More Posts by Dutchraptor
Last edited by Dutchraptor; Feb 25, 2013 at 11:39 AM.
Reply With Quote
Old Feb 25, 2013, 12:53 PM
Registered User
Dutchraptor's Avatar
The Netherlands, ZH, Hoogvliet
Joined Jul 2008
318 Posts
Pete, I hope you don't mind that I made some changes in your code (and put my name next to yours). If so, let me know, I will change it, if you want. The Raspberry now talks via serial to an Arduino. It reads an analog pin (A1) and reads pins 2->9. All pins have a 10K pulldown to ground. Now we can easily call 8 sounds by pushing a button (or in my case on the breadboard, connect two wires (5V to pin), yes I'm a bit lazy). Next step will be slicing the engine sound in a few steps and couple them to parts of the range from the analog pin.

Danny

EDIT: welcome text and exit on pin

Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Name:    serialsoundfx.py
Version: 0.0.3
Author:  blutoh and Dutchraptor
Purpose: using pygame mixer for rc boat sound effects with ArduinoRC control
Licence: gpl, see http://www.gnu.org/licenses/gpl.html
"""

import pygame
import time
import os
import serial

# initialization
pygame.mixer.pre_init(44100, -16, 2, 2048) # setup mixer to avoid sound lag
pygame.init()                              # initialize pygame

###############################################################################
#                        Basic Sound Effects System                           #
# The ambient effect is played like a music file. It begins when the sound    #
# system is started and continues after the engines are shutdown. All other   #
# effects are played at will.  The pygame mixer allows multiple (up to 8)     #
# sounds to be mixed and played simultaneously.                               #
# Serial commands between 1000 and 1500 are analog readings from arduino      #
# Serial commands between 2000 and 2255 are digital readings from arduino     #
#                                                                             #
# Replacing the menu with pin detection to trigger sound effects on arduino.  #
#                                                                             #
# Now this works, we can expand the functiongroups and functions              #
# The connection with a Nano with a NRF24L01 is also open or                  #
# a Arduino Mega with a NRF24L01 and functions hooked up                      #
#                                                                             #
# Ver: 0.0.3                                                                  #
# Have fun!                                                                   #
# Blutoh and Dutchraptor                                                      #
###############################################################################



# load up the necessary sound effects files for use
# sound effect files are in subfolder 'data', so join the path to the file name
try:
    pygame.mixer.music.load(os.path.join('data', 'ambient.ogg')) # ambient fx
    engStart = pygame.mixer.Sound(os.path.join('data','engStart.ogg')) # eng start 
    engRun = pygame.mixer.Sound(os.path.join('data','engRun.ogg'))
    engStop = pygame.mixer.Sound(os.path.join('data','engShutdown.ogg')) # eng stop
    horn = pygame.mixer.Sound(os.path.join('data','horn.ogg'))  # horn fx
    fogHorn = pygame.mixer.Sound(os.path.join('data','fogblast.ogg'))  # foghorn fx
    whistle = pygame.mixer.Sound(os.path.join('data','whistle.ogg'))  # whistle fx
except:
    raise UserWarning, "could not load or play soundfiles in 'data' folder :-("


pygame.mixer.music.play(-1)  # play ambient fx as background, see lines 74 & 81
pygame.mixer.music.set_volume(.625) # set ambient sound to 5/8ths volume


ARDUINO =  "/dev/ttyACM0" # lets setup the Arduino USB
print "Welcome to the Hybrid Serial Soundsystem"

def main():
        ser = serial.Serial(ARDUINO, 9600) # setting up serial
        prevVal = None

        while 1:
                # Read the serial value
                ser.flushInput()
                serialValue = ser.readline().strip()
                # Catch any bad serial data:
                try:
                        #c = convert + int(serialValue)
                        c = int(serialValue)
                except ValueError:
                        serialValue = 0
                try:
                        if serialValue != prevVal and c > 1000 and c < 1500:
                                # Print the value if it differs from the prevVal:
                                c = c - 1000 # bring back to normal 8 bit numbers
                                print "AnalogVal:",c, "  Serialreceive:",serialValue
                                prevVal = serialValue

                        elif serialValue != prevVal and c > 1999 and c < 2256:
                                c = c - 2000 #bring back to normal 8 bit numbers
                                try:
                                        if c == 0:
                                                print "All functions Off  8-Bitcommand:",c,  "  Serial command received:",serialValue
                                        if c >= 128:
                                                print "Function 1: on  8-Bitcommand:",c, "  Serial command received:",serialValue
                                                c = c -128
                                                engStart.play()            # play start effects
                                                time.sleep(6.5)            # pause to allow start effects to finish
                                                engRun.play(-1)            # run the engine sound continously in a loop
                                                #pygame.mixer.music.stop() # uncomment this line if you want ambient fx
                                                                           # to stop while engine sound is playing
                                        if c >= 64:
                                                print "Function 2: on  8-Bitcommand:",c, "  Serial command received:",serialValue
                                                c =c -64
                                                engStop.play()
                                                engRun.stop()
                                                time.sleep(8)                # pause to allow stop sequence to finish
                                                #pygame.mixer.music.play(-1) # If you uncommented line 74, then 
                                                                             # uncomment this line to start ambient effects
                                        if c >= 32:                          # toggle ambient sounds on/off
                                                print "Function 3: on  8-Bitcommand:",c, "  Serial command received:",serialValue
                                                c =c -32
                                                if pygame.mixer.music.get_busy():
                                                        pygame.mixer.music.stop()
                                                else:
                                                        pygame.mixer.music.play(-1)
                                        if c >= 16:
                                                print "Function 4: on  8-Bitcommand:",c, "  Serial command received:",serialValue
                                                c =c -16
                                                fogHorn.play()               # play foghorn
                                        if c >= 8:
                                                print "Function 5: on  8-Bitcommand:",c, "  Serial command received:",serialValue
                                                c =c -8
                                                horn.play()                  # play other horn
                                        if c >= 4:
                                                print "Function 6: on  8-Bitcommand:",c, "  Serial command received:",serialValue
                                                c =c -4
                                                whistle.play()               # play whistle
                                        if c >= 2:
                                                print "Function 7: on  8-Bitcommand:",c, "  Serial command received:",serialValue
                                                c =c -2
                                        if c >= 1:
                                                print "Function 8: on  8-Bitcommand:",c, "  Serial command received:",serialValue
                                                pygame.quit() # exit
                                except ValueError:
                                        pass

                except ValueError:
                        pass
                
if __name__ == '__main__':
    main()
Arduino code:

Code:
// constants won't change. They're used here to 
// set pin numbers:
const int buttonPin2 = 2;     // the number of the pushbutton pin
const int buttonPin3 = 3;     // the number of the pushbutton pin
const int buttonPin4 = 4;     // the number of the pushbutton pin
const int buttonPin5 = 5;     // the number of the pushbutton pin
const int buttonPin6 = 6;     // the number of the pushbutton pin
const int buttonPin7 = 7;     // the number of the pushbutton pin
const int buttonPin8 = 8;     // the number of the pushbutton pin
const int buttonPin9 = 9;     // the number of the pushbutton pin

const int analogInPin = A1;  // Analog input pin that the potentiometer is attached to
const int analogbuffer = 0; // 

// Variables will change:
int buttonState2; int lastButtonState2 = LOW;
int buttonState3; int lastButtonState3 = LOW;
int buttonState4; int lastButtonState4 = LOW;
int buttonState5; int lastButtonState5 = LOW;
int buttonState6; int lastButtonState6 = LOW;
int buttonState7; int lastButtonState7 = LOW;
int buttonState8; int lastButtonState8 = LOW;
int buttonState9; int lastButtonState9 = LOW;
int buttonSend = 2000;
int buttonSendOld = 0;
int Sending = 0;
  int sensorValue = 0;        // value read from the pot
  int outputValue = 0;        // value output to the PWM (analog out)
  int outputValueOld = 0;
  
// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0;  // the last time the output pin was toggled
long debounceDelay = 50;    // the debounce time; increase if the output flickers

void setup() {
    // initialize serial communications at 9600 bps:
  Serial.begin(9600);
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  pinMode(buttonPin4, INPUT); 
  pinMode(buttonPin5, INPUT);
  pinMode(buttonPin6, INPUT);
  pinMode(buttonPin7, INPUT); 
  pinMode(buttonPin8, INPUT); 
  pinMode(buttonPin9, INPUT); 
  
}

void loop() {
  // read the state of the switch into a local variable:
  int reading2 = digitalRead(buttonPin2);
  int reading3 = digitalRead(buttonPin3);
  int reading4 = digitalRead(buttonPin4);
  int reading5 = digitalRead(buttonPin5);
  int reading6 = digitalRead(buttonPin6);
  int reading7 = digitalRead(buttonPin7);
  int reading8 = digitalRead(buttonPin8);
  int reading9 = digitalRead(buttonPin9);  

  if (reading2 != lastButtonState2) {
    // reset the debouncing timer
    lastDebounceTime = millis();
        buttonState2 = reading2;
    if (reading2 == HIGH){buttonSend=buttonSend+128;}
    if (reading2 == LOW){buttonSend=buttonSend-128;}
  }
   if (reading3 != lastButtonState3) {
    // reset the debouncing timer
    lastDebounceTime = millis();
        buttonState3 = reading3;
    if (reading3 == HIGH){buttonSend=buttonSend+64;}
    if (reading3 == LOW){buttonSend=buttonSend-64;}
  } 
   if (reading4 != lastButtonState4) {
    // reset the debouncing timer
    lastDebounceTime = millis();
        buttonState4 = reading4;
    if (reading4 == HIGH){buttonSend=buttonSend+32;}
    if (reading4 == LOW){buttonSend=buttonSend-32;}
  }
   if (reading5 != lastButtonState5) {
    // reset the debouncing timer
    lastDebounceTime = millis();
        buttonState5 = reading5;
    if (reading5 == HIGH){buttonSend=buttonSend+16;}
    if (reading5 == LOW){buttonSend=buttonSend-16;}
  }
   if (reading6 != lastButtonState6) {
    // reset the debouncing timer
    lastDebounceTime = millis();
        buttonState6 = reading6;
    if (reading6 == HIGH){buttonSend=buttonSend+8;}
    if (reading6 == LOW){buttonSend=buttonSend-8;}
  }
   if (reading7 != lastButtonState7) {
    // reset the debouncing timer
    lastDebounceTime = millis();
        buttonState7 = reading7;
    if (reading7 == HIGH){buttonSend=buttonSend+4;}
    if (reading7 == LOW){buttonSend=buttonSend-4;}
  }
   if (reading8 != lastButtonState8) {
    // reset the debouncing timer
    lastDebounceTime = millis();
        buttonState8 = reading8;
    if (reading8 == HIGH){buttonSend=buttonSend+2;}
    if (reading8 == LOW){buttonSend=buttonSend-2;}
  }
   if (reading9 != lastButtonState9) {
    // reset the debouncing timer
    lastDebounceTime = millis();
        buttonState9 = reading9;
    if (reading9 == HIGH){buttonSend=buttonSend+1;}
    if (reading9 == LOW){buttonSend=buttonSend-1;}
  }  

  if ((millis() - lastDebounceTime) > debounceDelay) {
    // whatever the reading is at, it's been there for longer
    // than the debounce delay, so take it as the actual current state:
  }
  
  // save the reading.  Next time through the loop,
  // it'll be the lastButtonState:
  lastButtonState2 = reading2;
  lastButtonState3 = reading3;
  lastButtonState4 = reading4;
  lastButtonState5 = reading5;
  lastButtonState6 = reading6;
  lastButtonState7 = reading7;
  lastButtonState8 = reading8;
  lastButtonState9 = reading9;
  
    // read the analog in value:
  sensorValue = analogRead(analogInPin);            
  // map it to the range of the analog out:
  outputValue = map(sensorValue, 0, 1023, 1000, 1255);  

if (outputValue != outputValueOld){
  Serial.println(outputValue); 
outputValueOld = outputValue;
}
  
  // if anything changes in button state, send it
  if (buttonSend != buttonSendOld){
  Serial.println(buttonSend);
  buttonSendOld = buttonSend;}
  
  delay(20);
}
Dutchraptor is online now Find More Posts by Dutchraptor
Last edited by Dutchraptor; Feb 25, 2013 at 01:30 PM.
Reply With Quote
Old Feb 25, 2013, 01:31 PM
---o-O-o---
blutoh's Avatar
United States, NJ, Livingston
Joined Mar 2012
1,604 Posts
Danny,

I don't mind at all, in fact, I encourage it. As I said in the first post, this is a community project, Open Source. Right now it's just you an me in the community . But based on the view count, I think we have a lot of lurkers. Hopefully we'll get more participants as we go along, but if anyone is lurking, jump right in and speak up!

The code looks great, sending the value over the serial line is much more efficient, I didn't think we would get there so quickly. A few questions:
  • It appears that using this method avoids the "5v <-> 3.3v" issue between the two MCs?
  • Do you have a common ground between the Raspi and Arduino, or is it not necessary?
  • Did you have to disable the serial console in order to use the serial port, or is it not necessary?

Thanks,
Pete
blutoh is offline Find More Posts by blutoh
Reply With Quote
Old Feb 25, 2013, 01:47 PM
Registered User
Dutchraptor's Avatar
The Netherlands, ZH, Hoogvliet
Joined Jul 2008
318 Posts
The Arduino was programmed on my other computer. Once the program was on it, I just connected it to the USB port of the Raspberry. It did use the VIN and GND of the arduino te give it it own powersupply because else the pins and analog made the system instable. Apart from the USB I have no other connections to the Raspberry. I don't need the serial monitor for the Arduino, so connection was easy. If you really want to view what the arduino does, you can always use the softserial for that. But then you have to connect the arduino to the GPIO and use voltage dividers to bring it to 3.3V so the USB can be read by the ArduinoGUI. GND from the Arduino and Raspberry are connected to eachother throught the USB cable.

My setup is quit easy to build. The Arduino communication can be fully tested throught the serial monitor in the ArduinoGUI (both ways to and from the arduino). When everything works the way you want to, then it's time to connect it to the raspberry and start reading the values. I did nothing with the serial console. I didn't even know what it was untill now.

Hope it's all clear. Any questions, please ask.

Danny
Dutchraptor is online now Find More Posts by Dutchraptor
Reply With Quote
Old Feb 25, 2013, 01:58 PM
---o-O-o---
blutoh's Avatar
United States, NJ, Livingston
Joined Mar 2012
1,604 Posts
Danny,

OK, got it. Using the USB avoids a lot of issues. The serial console on the raspi doesn't even come into play (it's normally directed to the UART), so this is looking like a great communications method between the boards, eliminating many potential problems.

Pete
blutoh is offline Find More Posts by blutoh
Reply With Quote
Old Feb 25, 2013, 05:28 PM
---o-O-o---
blutoh's Avatar
United States, NJ, Livingston
Joined Mar 2012
1,604 Posts
Danny,

Had to make some changes to run on my raspi:
My default serialport is /dev/ttyAMA0 instead of /dev/ttyACM0, so I changed
ARDUINO = "/dev/ttyACM0" # lets setup the Arduino USB
TO
ARDUINO = "/dev/ttyAMA0" # lets setup the Arduino USB
Wheezy kept trying to spawn a getty terminal on ttyAMA0, so I commented out this line in /etc/inittab:
sudo nano /etc/inittab
comment out this line by putting the # at the beginning of the line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
reboot raspi:
sudo reboot
I'm not sure why there is a difference in the usb serial device name, trying to find out, but it's working now.

Pete

EDIT: For a quick synopsis and the latest installation package, go directly to this post.
blutoh is offline Find More Posts by blutoh
Last edited by blutoh; Apr 10, 2013 at 03:16 PM.
Reply With Quote
Old Feb 25, 2013, 06:52 PM
---o-O-o---
blutoh's Avatar
United States, NJ, Livingston
Joined Mar 2012
1,604 Posts
Quote:
Originally Posted by Dutchraptor View Post
finally found the way to make it work in the terminal: python ./name.py.........
I just saw your edit, Put this line at the top of your python programs (including the #):
#!/usr/bin/env python
This will point to the python interpreter and you wont have to include python on the command line.

Then set the permissons to executable with: chmod 755 filename.py

Then you can just type: ./name.py
to run the program

Pete
blutoh is offline Find More Posts by blutoh
Reply With Quote
Old Feb 26, 2013, 03:33 AM
Registered User
Dutchraptor's Avatar
The Netherlands, ZH, Hoogvliet
Joined Jul 2008
318 Posts
OK, I'll try that. Like I said before, I'm just learning Linux and Python, started about 4 or 5 days ago. I can use all the help there is. I'm not a programmer by profession, just learning by doing. The famous trail and error methode.

By the way, is there in the end a possibility to start the raspberry and automatically start the soundprogram? A small soundbit to attention the user that it has started up would also be nice then (is there a standard linux tune like windows when it starts?). Most of us don't have monitors in our boats (the 3,5" would look nice). I'm going to try and make a battery connection with a 5V regulator to the Raspberry. I read that I can use the 5V GPIO for that. There's also a pcb waiting for me to solder with a small amplifier (Velleman) for the sounds.

What's next? Are we going to send all the commands from the arduino system to the Raspberry? Or are we going to make a menu in the arduino program in which we can select with defines which commands are send and which not (my preference). That way we can also use sounds for cranes, helicopters, winches and so on. If we do that, we should probably name the sounds after the commands, in my case a crane sound would be for example 2064 for up. I think that will be our next challenge. How do we make it easy for everone to use.

Come on people, hop on board and join the fun. Even if you don't have a clue how to program. Give some ideas. There is a lot of knowlegde out there. This soundsystem and the Full Arduino Control system are open source. So everyone is invited to join in, make changes, expand and share. That way WE all can make it better and build ourselves a control system WE want. The big compagnies are letting us down by just making car, plane/heli transmitter with only 8 channels (max) or cost way to much. We only have the old models to choose from and the 2,4gHz isn't an option. That's one of the reason why I started to make my own system. Pete also has his reasons. But the main reason is FUN.

Danny
Dutchraptor is online now Find More Posts by Dutchraptor
Reply With Quote
Old Feb 26, 2013, 08:47 AM
---o-O-o---
blutoh's Avatar
United States, NJ, Livingston
Joined Mar 2012
1,604 Posts
Quote:
Originally Posted by Dutchraptor View Post
OK, I'll try that. Like I said before, I'm just learning Linux and Python, started about 4 or 5 days ago. I can use all the help there is. I'm not a programmer by profession, just learning by doing. The famous trail and error methode.
Your doing fine!

Quote:
Originally Posted by Dutchraptor View Post
By the way, is there in the end a possibility to start the raspberry and automatically start the soundprogram? A small soundbit to attention the user that it has started up would also be nice then (is there a standard linux tune like windows when it starts?).
Yes, we can have it auto start when the raspi boots, and also play a default startup sound. I'll start working on those today
Quote:
Originally Posted by Dutchraptor View Post
There's also a pcb waiting for me to solder with a small amplifier (Velleman) for the sounds.
Yes, I don't think the onboard amp in the raspi has enough power to drive a hefty speaker (4 - 6 " with a big magnet). There are lots of small battery powered amplifiers out there. I saw some on eBay for $15 US.

Quote:
Originally Posted by Dutchraptor View Post
............Or are we going to make a menu in the arduino program in which we can select with defines which commands are send and which not (my preference). That way we can also use sounds for cranes, helicopters, winches and so on. If we do that, we should probably name the sounds after the commands, in my case a crane sound would be for example 2064 for up. I think that will be our next challenge. How do we make it easy for everone to use.
Exactly. Thats why I named the sound objects "engStart, engRun engStop...." It makes it easy to understand whats happening when you read thru the code. We need consistency to keep any debugging issues to a minimum. Later I also want to develop an implementation for those who are not using the arduino control system , to be able to trigger sounds remotely. Some type of interface. Or maybe someone will jump in and work on that part (hows that for a public challenge! ) But we have to crawl before we walk.

Pete
blutoh is offline Find More Posts by blutoh
Reply With Quote
Old Feb 26, 2013, 09:45 AM
Registered User
Dutchraptor's Avatar
The Netherlands, ZH, Hoogvliet
Joined Jul 2008
318 Posts
Later I also want to develop an implementation for those who are not using the arduino control system , to be able to trigger sounds remotely. Some type of interface

That is not very hard to do with a little Arduino Nano translator that reads the channels of a standard receiver (codes to be found on the internet). Then it can throw the commands to the Raspberry. Who wants to pickup the challenge.

Danny
Dutchraptor is online now Find More Posts by Dutchraptor
Reply With Quote
Old Feb 26, 2013, 11:34 AM
---o-O-o---
blutoh's Avatar
United States, NJ, Livingston
Joined Mar 2012
1,604 Posts
New Files

The program has been modified to play a sound on startup, to signal that it's loaded. There is a new program, serialsoundfx.py, version 0.0.3b, and a new sound file, appStart.ogg, in the data folder. All files, old and new, are contained in the soundfx.zip archive file.

Pete


EDIT: For a quick synopsis and the latest installation package, go directly to this post.
blutoh is offline Find More Posts by blutoh
Last edited by blutoh; Apr 10, 2013 at 03:16 PM.
Reply With Quote
Old Feb 26, 2013, 01:17 PM
---o-O-o---
blutoh's Avatar
United States, NJ, Livingston
Joined Mar 2012
1,604 Posts
Danny,

I got the details worked out for autostarting the soundfx pkg on boot up. Had to create a shell script for the system to manage the execution of the program. The problem is that once it's configured, starting and stopping the soundfx program is going to be a big pain. So while we are still in development mode, I don't think we should implement that yet. Once we get close to production quality, then we can implement and test. Anyway, here are the details:

EDIT: An additional step added: Change the path path for all sound files to explicit, necessary when the program runs as a system service only (autostart):

Example:
pygame.mixer.music.load(os.path.join('/home/pi/soundfx/data', 'ambient.ogg'))
Change the file permissions on the script: chmod 755 startsoundfx

Copy the startsoundfx script to /etc/init.d: sudo cp ./startsoundfx /etc/init.d/startsoundfx

Register the application: sudo update-rc.d startsoundfx defaults

To manually start the program: sudo /etc/init.d/startsoundfx start

To manually stop the program: sudo /etc/init.d/startsoundfx stop

To remove the script from auto start-up: sudo update-rc.d -f startsoundfx remove

Shell script 'startsoundfx' code:

deprecated see current version
blutoh is offline Find More Posts by blutoh
Last edited by blutoh; Jun 01, 2013 at 12:45 PM. Reason: spelling
Reply With Quote
Reply


Thread Tools