text:
Q: JSlider issue audio player I am trying to build an audio player with an integrated JSlider, which updates the interface every microsecond.
In order to do so I am using the following:
sliderTime.setMinimum(0);
sliderTime.setMaximum((int) audioClip.getMicrosecondPosition(););

I have the feeling that this is not the best implementation out there (any suggestions to improve it is highly appreciated)
By the way, the issue I am facing is that for the first second the JSlider does not update.
Please find MCVE below:
It plays only wav uncompressed files
Main
public class Main
{
    public static void main(final String[] args)
    {
        SwingUtilities.invokeLater(new Runnable()
        {
             @Override
             public void run()
             {
                 JFrame f = new JFrame();
                 PlayerView pw = new PlayerView();
                 Border border = new EmptyBorder(15,15,15,15);
                 pw.setBorder(border);
                 f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                 f.getContentPane().setLayout(new BorderLayout());
                 f.getContentPane().add(pw, BorderLayout.CENTER);
                 f.pack();
                 f.setLocationRelativeTo(null);
                 f.setVisible(true);
             }
        });
    }
}

AudioPlayer
public class AudioPlayer implements LineListener
{
    private SimpleDateFormat dateFormater = new SimpleDateFormat("HH:mm:ss.SSS");
    private TimeZone timeZone = Calendar.getInstance().getTimeZone();

    public static final int REWIND_IN_MICROSECONDS = 3000000;
    public static final int FORWARD_IN_MICROSECONDS = 3000000;

    private boolean playCompleted;
    private boolean isStopped;
    private boolean isPaused;
    private boolean isRewinded;
    private boolean isForwarded;

    private Clip audioClip;

    public Clip getAudioClip()
    {
        return audioClip;
    }

    public void load(String audioFilePath) throws UnsupportedAudioFileException, IOException, LineUnavailableException
    {
        File encodedFile = new File(audioFilePath);
        AudioInputStream pcmStream = AudioSystem.getAudioInputStream(encodedFile);
        AudioFormat format =pcmStream.getFormat();
        DataLine.Info info = new DataLine.Info(Clip.class, format);
        audioClip = (Clip) AudioSystem.getLine(info);
        audioClip.addLineListener(this);
        audioClip.open(pcmStream);
    }

    public long getClipMicroSecondLength()
    {
        return audioClip.getMicrosecondLength();
    }

    public long getClipMicroSecondPosition()
    {
        return audioClip.getMicrosecondPosition();
    }

    public String getClipLengthString()
    {
        long yourmilliseconds = audioClip.getMicrosecondLength() / 1_000;
        Date resultdate = new Date(yourmilliseconds);
        dateFormater.setTimeZone(TimeZone.getTimeZone(timeZone.getDisplayName(false, TimeZone.SHORT)));
        return dateFormater.format(resultdate);
    }

    public void play() throws IOException
    {
        audioClip.start();

        playCompleted = false;
        isStopped = false;

        while (!playCompleted)
        {
            try
            {
                Thread.sleep(30);
            }
            catch (InterruptedException ex)
            {
                if (isStopped)
                {
                    audioClip.stop();
                    break;
                }
                else if (isPaused)
                {
                    audioClip.stop();
                }
                else if (isRewinded)
                {
                    if( audioClip.getMicrosecondPosition() <= REWIND_IN_MICROSECONDS)
                    {
                        audioClip.setMicrosecondPosition(0);
                        isRewinded =false;
                    }
                    else
                    {
                        audioClip.setMicrosecondPosition(audioClip.getMicrosecondPosition() - REWIND_IN_MICROSECONDS);
                        isRewinded =false;
                    }
                }
                else if (isForwarded)
                {
                    if((audioClip.getMicrosecondLength() - audioClip.getMicrosecondPosition()) >= FORWARD_IN_MICROSECONDS)
                    {
                        audioClip.setMicrosecondPosition(audioClip.getMicrosecondPosition() + FORWARD_IN_MICROSECONDS);
                        isForwarded =false;
                    }
                    else
                    {
                        audioClip.stop();
                        isForwarded =false;
                    }
                }
                else
                {
                    audioClip.start();
                }
            }
        }
        audioClip.close();
    }

    public void stop()
    {
        isStopped = true;
    }

    public void pause()
    {
        isPaused = true;
    }

    public void resume()
    {
        isPaused = false;
    }

    public void rewind()
    {
        isRewinded = true;
    }

    public void forward()
    {
        isForwarded = true;
    }

    @Override
    public void update(LineEvent event)
    {
        Type type = event.getType();
        if (type == Type.STOP)
        {
            if (isStopped || !isPaused)
            {
                playCompleted = true;
            }
        }
    }
}

PlayingTimer
public class PlayingTimer extends Thread
{
    private SimpleDateFormat dateFormater = new SimpleDateFormat("HH:mm:ss.SSS");
    private TimeZone timeZone = Calendar.getInstance().getTimeZone();

    private boolean isRunning = false;
    private boolean isPause = false;
    private boolean isReset = false;
    private boolean isRewinded = false;
    private boolean isForwarded = false;

    private long startTime;
    private long pauseTime;
    private long rewindTime;
    private long forwardTime;

    private JLabel labelRecordTime;
    private JSlider slider;
    private Clip audioClip;

    public void setAudioClip(Clip audioClip)
    {
        this.audioClip = audioClip;
    }

    public PlayingTimer(JLabel labelRecordTime, JSlider slider)
    {
        this.labelRecordTime = labelRecordTime;
        this.slider = slider;
        dateFormater.setTimeZone(TimeZone.getTimeZone(timeZone.getDisplayName(false, TimeZone.SHORT)));
    }

    public void run()
    {
        isRunning = true;
        startTime = System.currentTimeMillis();

        while (isRunning)
        {
            try
            {
                Thread.sleep(30);
                if (!isPause)
                {
                    if (audioClip != null && audioClip.isRunning())
                    {
                         long currentMicros = audioClip.getMicrosecondPosition();

                            // Compute the progress as a value between 0.0 and 1.0
                            double progress =
                                (double)currentMicros / audioClip.getMicrosecondLength();

                            // Compute the slider value to indicate the progress
                            final int sliderValue = (int)(progress * slider.getMaximum());

                            // Update the slider with the new value, on the Event Dispatch Thread
                            SwingUtilities.invokeLater(new Runnable()
                            {
                                @Override
                                public void run()
                                {
                                    labelRecordTime.setText(toTimeString());
                                    slider.setValue(sliderValue);
                                }
                            });
                    }
                }
                else
                {
                    pauseTime += 30;
                }
            }
            catch (InterruptedException ex)
            {
                if (isReset)
                {
                    slider.setValue(0);
                    labelRecordTime.setText("00:00:00.000");
                    isRunning = false;
                    break;
                }
                if (isRewinded)
                {
                    if( audioClip.getMicrosecondPosition() <= AudioPlayer.REWIND_IN_MICROSECONDS)
                    {
                        //go back to start
                        rewindTime += audioClip.getMicrosecondPosition() / 1_000;
                    }
                    else
                    {
                        rewindTime += 3000;
                    }
                    isRewinded =false;
                }
                if (isForwarded)
                {
                    if((audioClip.getMicrosecondLength()- audioClip.getMicrosecondPosition()) <= AudioPlayer.FORWARD_IN_MICROSECONDS)
                    {
                        forwardTime -= (audioClip.getMicrosecondLength()- audioClip.getMicrosecondPosition())/1_000;
                    }
                    else
                    {
                        forwardTime -= 3000;
                    }
                    isForwarded=false;
                }
            }
        }
    }

    public void reset()
    {
        isReset = true;
        isRunning = false;
    }

    public void rewind()
    {
        isRewinded = true;
    }

    public void forward()
    {
        isForwarded = true;
    }

    public void pauseTimer()
    {
        isPause = true;
    }

    public void resumeTimer()
    {
        isPause = false;
    }

    private String toTimeString()
    {
        long now = System.currentTimeMillis();
        Date resultdate = new Date(now - startTime - pauseTime - rewindTime - forwardTime);
        return dateFormater.format(resultdate);
    }

}

PlayerView
 public class PlayerView extends JPanel implements ActionListener
   {

        private static final int BUTTON_HEIGTH =60;
        private static final int BUTTON_WIDTH =120;

        private AudioPlayer player = new AudioPlayer();
        private Thread playbackThread;
        private PlayingTimer timer;

        private boolean isPlaying = false;
        private boolean isPause = false;

        private String audioFilePath;
        private String lastOpenPath;

        private JLabel labelFileName;
        private JLabel labelTimeCounter;
        private JLabel labelDuration;

        private JButton buttonOpen;
        private JButton buttonPlay;
        private JButton buttonPause;
        private JButton buttonRewind;
        private JButton buttonForward;

        private JSlider sliderTime;

        private Dimension buttonDimension = new Dimension(BUTTON_WIDTH,BUTTON_HEIGTH);

        public PlayerView()
        {
            setLayout(new BorderLayout());
            labelFileName = new JLabel("File Loaded:");

            labelTimeCounter = new JLabel("00:00:00.000");
            labelDuration = new JLabel("00:00:00.000");

            sliderTime = new JSlider(0, 1000, 0);;
            sliderTime.setValue(0);
            sliderTime.setEnabled(false);

            buttonOpen   = new JButton("Open");
            buttonOpen.setPreferredSize(buttonDimension);
            buttonOpen.addActionListener(this);

            buttonPlay   = new JButton("Play");

            buttonPlay.setEnabled(false);
            buttonPlay.setPreferredSize(buttonDimension);
            buttonPlay.addActionListener(this);

            buttonPause  = new JButton("Pause");
            buttonPause.setEnabled(false);
            buttonPause.setPreferredSize(buttonDimension);
            buttonPause.addActionListener(this);

            buttonRewind = new JButton("Rewind");
            buttonRewind.setEnabled(false);
            buttonRewind.setPreferredSize(buttonDimension);
            buttonRewind.addActionListener(this);

            buttonForward= new JButton("Forward");
            buttonForward.setEnabled(false);
            buttonForward.setPreferredSize(buttonDimension);
            buttonForward.addActionListener(this);

            init();

        }

        public void enableButtonPlay()
        {
            buttonPlay.setEnabled(true);
        }

        @Override
        public void actionPerformed(ActionEvent event)
        {
            Object source = event.getSource();
            if (source instanceof JButton)
            {
                JButton button = (JButton) source;
                if (button == buttonOpen)
                {
                    openFile();
                }
                else if (button == buttonPlay)
                {
                    if (!isPlaying)
                    {
                        playBack();
                    }
                    else
                    {
                        stopPlaying();
                    }
                }
                else if (button == buttonPause)
                {
                    if (!isPause)
                    {
                        pausePlaying();
                    }
                    else
                    {
                        resumePlaying();
                    }
                }
                else if (button == buttonRewind)
                {
                    if (!isPause)
                    {
                        rewind();
                    }
                }
                else if (button == buttonForward)
                {
                    if (!isPause)
                    {
                        forward();
                    }
                }
            }
        }

        public void openFile(String path)
        {
            audioFilePath = path ;

            if (isPlaying || isPause)
            {
                stopPlaying();
                while (player.getAudioClip().isRunning())
                {
                    try
                    {
                        Thread.sleep(100);
                    }
                    catch (InterruptedException ex)
                    {
                        ex.printStackTrace();
                    }
                }
            }
            playBack();
        }

        private void openFile()
        {
            JFileChooser fileChooser = null;

            if (lastOpenPath != null && !lastOpenPath.equals(""))
            {
                fileChooser = new JFileChooser(lastOpenPath);
            }
            else
            {
                fileChooser = new JFileChooser();
            }

            FileFilter wavFilter = new FileFilter()
            {
                @Override
                public String getDescription()
                {
                    return "Sound file (*.WAV)";
                }

                @Override
                public boolean accept(File file)
                {
                    if (file.isDirectory())
                    {
                        return true;
                    }
                    else
                    {
                        return file.getName().toLowerCase().endsWith(".wav");
                    }
                }
            };

            fileChooser.setFileFilter(wavFilter);
            fileChooser.setDialogTitle("Open Audio File");
            fileChooser.setAcceptAllFileFilterUsed(false);

            int userChoice = fileChooser.showOpenDialog(this);
            if (userChoice == JFileChooser.APPROVE_OPTION)
            {
                audioFilePath = fileChooser.getSelectedFile().getAbsolutePath();
                lastOpenPath = fileChooser.getSelectedFile().getParent();

                if (isPlaying || isPause)
                {
                    stopPlaying();
                    while (player.getAudioClip().isRunning())
                    {
                        try
                        {
                            Thread.sleep(100);
                        }
                        catch (InterruptedException ex)
                        {
                            ex.printStackTrace();
                        }
                    }
                }
                playBack();
            }
        }

        private void playBack()
        {
            timer = new PlayingTimer(labelTimeCounter, sliderTime);

            timer.start();
            isPlaying = true;

            playbackThread = new Thread(new Runnable()
            {
                @Override
                public void run()
                {
                    try
                    {
                        buttonPlay.setText("Stop");
                        buttonPlay.setEnabled(true);

                        buttonRewind.setEnabled(true);
                        buttonForward.setEnabled(true);

                        buttonPause.setText("Pause");
                        buttonPause.setEnabled(true);

                        player.load(audioFilePath);

                        timer.setAudioClip(player.getAudioClip());

                        labelFileName.setText("Playing File: " + ((File)new File(audioFilePath)).getName());

                        sliderTime.setMinimum(0);
                        sliderTime.setMaximum((int)player.getClipMicroSecondLength());

                        labelDuration.setText(player.getClipLengthString());

                        player.play();
                        labelFileName.setText("File Loaded: " + ((File)new File(audioFilePath)).getName());
                        resetControls();

                    }
                    catch (UnsupportedAudioFileException ex)
                    {
                        JOptionPane.showMessageDialog(
                            PlayerView.this,
                            "The audio format is unsupported!",
                            "Error",
                            JOptionPane.ERROR_MESSAGE);
                        resetControls();
                    }
                    catch (LineUnavailableException ex)
                    {
                        JOptionPane.showMessageDialog(
                            PlayerView.this,
                            "Could not play the audio file because line is unavailable!",
                            "Error",
                            JOptionPane.ERROR_MESSAGE);
                        resetControls();
                    }
                    catch (IOException ex)
                    {
                        JOptionPane.showMessageDialog(
                            PlayerView.this,
                            "I/O error while playing the audio file!",
                            "Error",
                            JOptionPane.ERROR_MESSAGE);
                        resetControls();
                    }
                }
            });

            playbackThread.start();
        }

        private void stopPlaying()
        {
            isPause = false;

            buttonPause.setText(" Pause ");
            buttonPause.setEnabled(false);
            buttonRewind.setEnabled(false);
            buttonForward.setEnabled(false);

            timer.reset();
            timer.interrupt();

            player.stop();
            playbackThread.interrupt();
        }

        private void pausePlaying()
        {
            labelFileName.setText("File Loaded: " + ((File)new File(audioFilePath)).getName());
            buttonRewind.setEnabled(false);
            buttonForward.setEnabled(false);

            buttonPause.setText("Resume");
            isPause = true;

            player.pause();
            timer.pauseTimer();

            playbackThread.interrupt();
        }

        private void resumePlaying()
        {
            labelFileName.setText("Playing File: " +  ((File)new File(audioFilePath)).getName());
            buttonPause.setText(" Pause ");
            buttonRewind.setEnabled(true);
            buttonForward.setEnabled(true);
            isPause = false;

            player.resume();
            timer.resumeTimer();

            playbackThread.interrupt();
        }

        private void rewind()
        {
            player.rewind();
            timer.rewind();
            timer.interrupt();
            playbackThread.interrupt();
        }

        private void forward()
        {
            player.forward();
            timer.forward();
            timer.interrupt();
            playbackThread.interrupt();
        }

        private void resetControls()
        {
            timer.reset();
            timer.interrupt();
            isPlaying = false;

            buttonPlay.setText("Play");

            buttonPause.setEnabled(false);
            buttonRewind.setEnabled(false);
            buttonForward.setEnabled(false);
        }

        private void init()
        {

            add(labelFileName, BorderLayout.NORTH);
            add(labelTimeCounter, BorderLayout.WEST);
            add(labelDuration, BorderLayout.EAST);
            add(sliderTime, BorderLayout.CENTER);

            JPanel buttonContainer =new JPanel();
            add(buttonContainer, BorderLayout.SOUTH);

            buttonContainer.add(buttonOpen);
            buttonContainer.add(buttonPlay);
            buttonContainer.add(buttonPause);
            buttonContainer.add(buttonRewind);
            buttonContainer.add(buttonForward);

        }
}

A: I assume you are wanting to use the JSlider as a progress bar and that at the moment you are setting the max value, the current position is at the end of the audioClip. (Are you dealing with Clip or AudioClip? AudioClip doesn't have a way to read its position AFAIK.)  If you are using Clip, it would be safer to set the max with audioClip.getMicrosecondLength().
Since the audio has to play on a different thread than the one where the JSlider is being updated, I'd recommend making your audioClip a volatile variable. That might help with cross-thread weirdness that sometimes occurs.
Thread.sleep(1) at best can only update every millisecond. On some systems (older Windows) the method's reliance on the system clock means the actual updates are as slow as 16 millis apart. But updating the JSlider at more than 60 fps is probably moot. Screen monitors often are set to 60Hz, and there's only so much the human eye can take in.
Also there is only so much the ear can discern in terms of timing. For example, it is hard to tell if two percussive events happen at the same time if there is less than a couple milliseconds difference.

A: There are several issues with your code.
As Phil Freihofner pointed out, the sleep(1) and the treatment of the isRunning and isPause fields look highly dubious. To some extent, this is unrelated to your actual question, but worth noting here, because it may also cause problems later.
Regardless of that, the approach that Zoran Regvart showed is basically the way to go. The code in the given form may have suffered from some rounding issues. However, the general idea for cases like this is always the same:

*

*You have a source interval [minA...maxA]

*You have a target interval [minB...maxB]

*You want a mapping between the two

In this case, it's a good practice to normalize the intervals. That is, to map the value from the source interval to a value between 0.0 and 1.0, and then map this normalized value to the target interval.
In the most generic form, this can be written as
long minA = ...
long maxA = ...
long a = ... // The current value in the source interval
int minB = ...
int maxB = ...
int b; // The value to compute in the target interval

// Map the first value to a value between 0.0 and 1.0
double normalized = (double)(a - minA)/(maxA-minA);
b = (int)(minB + normalized * (maxB - minB));

Fortunately, your "min" values are all zero here, so it's a bit simpler. Here is a MCVE (with some dummy classes). The most relevant part is the updateSlider method at the bottom.
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JSlider;
import javax.swing.SwingUtilities;

public class SliderMappingTest
{
    public static void main(String[] args)
    {
        SwingUtilities.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {
                createAndShowGUI();
            }
        });
    }

    private static void createAndShowGUI()
    {
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        final JButton startButton = new JButton("Start");
        final JSlider progressSlider = new JSlider(0, 1000, 0);

        startButton.addActionListener(new ActionListener()
        {
            @Override
            public void actionPerformed(ActionEvent e)
            {
                startButton.setEnabled(false);
                SliderMappingDummyAudioClip audioClip =
                    new SliderMappingDummyAudioClip();
                SliderMappingDummyPlayer player =
                    new SliderMappingDummyPlayer(progressSlider, audioClip);
                player.start();
            }
        });

        f.getContentPane().setLayout(new GridLayout());
        f.getContentPane().add(startButton);
        f.getContentPane().add(progressSlider);

        f.pack();
        f.setLocationRelativeTo(null);
        f.setVisible(true);
    }
}

class SliderMappingDummyAudioClip
{
    private long startMicros;

    void start()
    {
        startMicros = System.nanoTime() / 1000L;
    }

    long getMicrosecondLength()
    {
        // 10 seconds
        return 10L * 1000L * 1000L;
    }

    long getMicrosecondPosition()
    {
        return (System.nanoTime() / 1000L) - startMicros;
    }

    public boolean isRunning()
    {
        return getMicrosecondPosition() <= getMicrosecondLength();
    }

}

class SliderMappingDummyPlayer
{
    private final SliderMappingDummyAudioClip audioClip;
    private final JSlider slider;

    SliderMappingDummyPlayer(
        JSlider slider,
        SliderMappingDummyAudioClip audioClip)
    {
        this.slider = slider;
        this.audioClip = audioClip;
    }

    void start()
    {
        Thread t = new Thread(new Runnable()
        {
            @Override
            public void run()
            {
                doRun();
            }
        });
        t.setDaemon(true);
        t.start();
    }

    private void doRun()
    {
        audioClip.start();
        while (audioClip.isRunning())
        {
            updateSlider();
            try
            {
                Thread.sleep(30);
            }
            catch (InterruptedException ex)
            {
                Thread.currentThread().interrupt();
                return;
            }
        }
    }

    private void updateSlider()
    {
        long currentMicros = audioClip.getMicrosecondPosition();

        // Compute the progress as a value between 0.0 and 1.0
        double progress =
            (double)currentMicros / audioClip.getMicrosecondLength();

        // Compute the slider value to indicate the progress
        final int sliderValue = (int)(progress * slider.getMaximum());

        System.out.println("update "+progress);

        // Update the slider with the new value, on the Event Dispatch Thread
        SwingUtilities.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {
                slider.setValue(sliderValue);
            }
        });
    }

}

A: Okay, so, the issue with Clip. Here is an MCVE that, from the way you've described the problem, may reproduce it:
class TestFramePosition {
    public static void main(String[] a) throws Exception {
        File file = new File(a.length > 0 ? a[0] : "path/to/file.extension");
        AudioInputStream ais = AudioSystem.getAudioInputStream(file);
        final Clip clip = AudioSystem.getClip();

        clip.open(ais);
        clip.start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                while(clip.isRunning()) {
                    try {
                        System.out.println(clip.getMicrosecondPosition());
                        Thread.sleep(1000 / 10);
                    } catch(InterruptedException ignored) {}
                }
            }
        }).start();

        System.in.read();
        System.exit(0);
    }
}

I was unable to reproduce it on OSX 10.6.8 and Windows XP, but you may run that code to see if it does on your particular platform.
So, the issue here is that, as I said in comments, since sound playback is dependent on platform-specific stuff, classes like Clip will have varied implementations. These will behave slightly differently.
For example, I found that when a Clip is done playing, the Clip on my Mac computer (a com.sun.media.sound.MixerClip) returns 0 for the position, while the Clip on my Windows computer (a com.sun.media.sound.DirectAudioDevice$DirectClip) returns the maximum value for the position. Just another small example of implementations being programmed differently.
The issue is that the contract for these methods is defined a little vaguely but, specifically, it is defined by 'the number of sample frames captured by, or rendered from, the line since it was opened'. This means it may not accurately represent the playback position, rather it is the amount of data read and written.
I did spend awhile yesterday perusing JDK source code but I was unable to find anything that would point towards the behavior you are seeing.
Anyway, what it comes down to is whether you are OK with slightly anomalous behavioral differences from platform to platform. What you are seeing may be a bug and if the above MCVE reproduces it, you may report it; however I would not personally expect it to get fixed in any timely manner because this is a section of the JDK that does not get a lot of attention. Also it is gradually being superseded by JavaFX.
Some other things:

*

*You are sharing state between threads without synchronization. This leads to memory errors. You should read the concurrency tutorials, specifically synchronization.

*You should always cap frame rate when working with Swing. Swing will not paint at 1000FPS, it will merge repaints aggressively. Updating the slider at this rate was just flooding the EDT.

You may use SourceDataLine because it gives you much greater control over the buffering behavior. The downside is that you have to basically reimplement the functionality of Clip.
Here is an MCVE demonstrating a playback loop to power a JSlider.

This example doesn't demonstrate seeking. Also since, AudioInputStream does not generally support mark operations, seeking backwards is a bit of a hassle. A backwards seek process is:

*

*Stop the current playback and discard it.

*Create a new AudioInputStream and seek forwards.

*Start the new playback.

Also, if you are planning to use the JSlider to seek, you will probably run in to an issue where calling setValue on a JSlider will cause it to fire a ChangeEvent. So you can't update the slider's value programmatically and also listen to it without rejiggering it. This is really a Q&A itself so if you experience this problem I recommend you ask a new question.
import javax.sound.sampled.*;
import javax.swing.*;
import java.awt.event.*;

import java.awt.Dimension;
import java.awt.BorderLayout;
import java.io.File;
import java.io.IOException;

public class PlaybackSlider implements Runnable, ActionListener {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new PlaybackSlider());
    }

    JButton open;
    JButton play;
    JSlider slider;
    JLabel label;

    File file;
    PlaybackLoop player;

    @Override
    public void run() {
        JFrame frame = new JFrame("Playback Slider");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel content = new JPanel(new BorderLayout()) {
            @Override
            public Dimension getPreferredSize() {
                Dimension pref = super.getPreferredSize();
                pref.width = 480;
                return pref;
            }
        };

        slider = new JSlider(JSlider.HORIZONTAL, 0, 1000, 0);
        content.add(slider, BorderLayout.CENTER);

        JToolBar bar = new JToolBar(JToolBar.HORIZONTAL);
        bar.setFloatable(false);
        content.add(bar, BorderLayout.SOUTH);

        open = new JButton("Open");
        play = new JButton("Play");

        open.addActionListener(this);
        play.addActionListener(this);

        label = new JLabel("");

        bar.add(open);
        bar.add(new JLabel(" "));
        bar.add(play);
        bar.add(new JLabel(" "));
        bar.add(label);

        frame.setContentPane(content);
        frame.pack();
        frame.setResizable(false);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent ae) {
        Object source = ae.getSource();

        if(source == open) {
            File f = getFile();
            if(f != null) {
                file = f;
                label.setText(file.getName());
                stop();
            }
        }

        if(source == play) {
            if(file != null) {
                if(player != null) {
                    stop();
                } else {
                    start();
                }
            }
        }
    }

    File getFile() {
        JFileChooser diag = new JFileChooser();
        int choice = diag.showOpenDialog(null);

        if(choice == JFileChooser.APPROVE_OPTION) {
            return diag.getSelectedFile();
        } else {
            return null;
        }
    }

    void start() {
        try {
            player = new PlaybackLoop(file);
            new Thread(player).start();
            play.setText("Stop");
        } catch(Exception e) {
            player = null;
            showError("the file couldn't be played", e);
        }
    }

    void stop() {
        if(player != null) {
            player.stop();
        }
    }

    void showError(String msg, Throwable cause) {
        JOptionPane.showMessageDialog(null,
            "There was an error because " + msg +
            (cause == null ? "." : "\n(" + cause + ").")
        );
    }

    class PlaybackLoop implements Runnable {
        AudioInputStream in;
        SourceDataLine line;
        AudioFormat fmt;
        int bufferSize;

        boolean stopped;

        PlaybackLoop(File file) throws Exception {
            try {
                in = AudioSystem.getAudioInputStream(file);
                fmt = in.getFormat();

                bufferSize = (int)(fmt.getFrameSize() * (fmt.getSampleRate() / 15));

                line = AudioSystem.getSourceDataLine(fmt);
                line.open(fmt, bufferSize);
            } catch(Exception e) {
                if(in != null)
                    in.close();
                if(line != null)
                    line.close();
                throw e;
            }
        }

        void stop() {
            synchronized(this) {
                this.stopped = true;
            }
        }

        @Override
        public void run() {
            line.start();
            byte[] buf = new byte[bufferSize];

            try {
                try {
                    int b;
                    long elapsed = 0;
                    long total = in.getFrameLength();

                    for(;;) {
                        synchronized(this) {
                            if(stopped) {
                                break;
                            }
                        }

                        b = in.read(buf, 0, buf.length);
                        if(b < 0) {
                            break;
                        }

                        elapsed += b / fmt.getFrameSize();
                        updateSlider(elapsed, total);

                        line.write(buf, 0, b);
                    }
                } finally {
                    line.close();
                    in.close();
                }
            } catch(IOException e) {
                e.printStackTrace(System.err);
                showError("there was a problem during playback", e);
            }

            endOnEDT();
        }

        void updateSlider(double elapsed, double total) {
            final double amt = elapsed / total;
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    slider.setValue((int)Math.round(slider.getMaximum() * amt));
                }
            });
        }

        void endOnEDT() {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    player = null;
                    slider.setValue(0);
                    play.setText("Play");
                }
            });
        }
    }
}

A: Are you sure you want to set the maximum to current position?
How about mapping longs to ints by division:
long coefficient = clip.getMicrosecondLength() / Integer.MAX_VALUE;

slider.setMinimum(0);
slider.setMaximum((int) (clip.getMicrosecondLength() / coefficient));
...
slider.setValue((int) (clip.getMicrosecondPosition() / coefficient));


text:
MMR Forecast Calculator
Receipt Generator
Free Tools By Receipt Cat
MRR Forecast Calculator
Forecast the monthly recurring revenue growth of your SaaS business.
Starting Amount
Growth Percentage
"; tableHTML = tableHTML + "
"; } tableHTML = tableHTML + "
"; document.getElementById("chartTable").innerHTML = tableHTML; Highcharts.chart('chart', { colors: ['#EA580C'], data: { table: 'datatable' }, chart: { type: 'line' }, title: { text: 'Forecasted Revenue', margin: 30 }, yAxis: { allowDecimals: false, title: { text: 'Revenue' } }, xAxis: { allowDecimals: false, title: { text: 'Months' } }, tooltip: { formatter: function () { return 'Month ' + this.point.x + '
' + this.series.name + '
$' + this.point.y.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } }, legend:{ enabled:false }, }); $("#noData").hide(); }
"Success isn't always about greatness. It's about consistency. Consistent hard work leads to success. Greatness will come."
- Dwayne Johnson
How To Forecast Your Monthly Recurring Revenue (MRR)
Forecasting your MRR is important to growing your SaaS business. Being able to project your sales can help you understand where your company will be in the future, and how much money you could potentially earn in the future. You'll be able to plan for expenses and make strategic service decisions that can help take your company to the next level.
MRR Defined
MRR stands for monthly recurring revenue, and it's an important metric for your SaaS business.
MRR is a measure of the amount of money you make from your subscriptions each month, or how much you can expect to earn from those subscriptions in the future.
The easiest way to understand MRR is to think about it as your recurring revenue—the amount of money you have coming in every month without having to do anything new. The higher your MRR, the more stable your business will be!
Forecast Growth Based on Historical Data
You should forecast growth based on historical data because it is the most accurate and reliable way to predict future growth.
First, consider the past. If you have a long-term history of growth, you can extrapolate that data to predict how your business will perform in the future. This method is not perfect, but it has been proven to be more reliable than any other method.
Second, consider how aggressively you want to grow. If you are looking for aggressive growth, this method is best suited for what you're trying to achieve. You can use historical data to determine how much growth is necessary before your company reaches its maximum potential size.
Be Honest with Yourself about Future Growth
I'm sure you've heard the old saying: "The sky is the limit." And while it's true that there are no limits to how high your business can go, it's important to be realistic and honest with yourself about how much growth you can expect over time.
It's easy to get caught up in the hype of a new product or service and dream of all the money you'll make. But if you're not careful, those dreams can end up becoming nightmares if you don't set reasonable goals for yourself.
Your first year of business might not be as profitable as you expect. This is especially true for companies just starting out; but even established SaaS businesses have their share of surprises. It's important to know what those surprises might look like so that you don't get discouraged when they happen (and they will).
Be Aware of Your Churn Rate
If you're not paying attention to your churn rate, then you're missing out on a big opportunity.
Churn rate is the percentage of customers that leave your business over a specific period of time. It's important because it gives you an idea of how many customers are leaving and why they're doing so. If your churn rate is high, then it means that a lot of people are leaving your service or product—and if you don't know why, then you won't be able to fix it!
That's why we recommend always being aware of your churn rate and working towards reducing it as much as possible. It will allow you to stay on top of the problems that are causing people to leave and make sure that everyone who is using your product or service is getting everything they need from it.
Forecasting Your MRR Is Important to Growing Your SaaS Business
When you forecast your MRR, you're making an educated guess about how much money you can make in the future. It's a vital step in deciding whether or not to expand your SaaS business. If forecasting your MRR comes with a serious risk of failure, then it won't help you decide if your current business model is worth continuing. There are many different ways to calculate MRR, so remember the tips above and good luck with your growth!
Free Receipt & Invoice Generator
Generate professional receipts and invoices for free with our online tool.
How Much Money to Set Aside for Taxes
Understand how much money you should set aside for taxes.
Monthly Revenue Forecast Calculator
Forecast your MRR to see how your business could perform over time.
A Guide to Small Business Tax Deductions
A comprehensive list of everything you could write-off this tax season.
Receipt Cat is an online tool that helps you keep track of your business receipts and manage your small business expenses. Receipt cat is for freelancers, indie developers, or other sole proprietors who don't want to manage complex accounting software.
Copyright 2023 Receipt Cat by Jordan Kennedy
Sign Up Log In Contact Blog
Free Receipt Generator MRR Forecast Calculator Privacy Policy Terms of Use

redpajama_set_name: RedPajamaCommonCrawl


text:
Q: Grid Layout Java I have created a java program that shows a grid of buttons and labels and i want to know how to pit a constraint on the labels and buttons so they dont re-size when window is dragged out.. can anyone help please?
this is my gridlayout class
package JFrameTester;

import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class layout extends JFrame {

    JButton button1,button2,button3;
    JLabel label1,Label2,Label3;

    public layout (){

    setLayout(new GridLayout(2, 2));

    button1 =  new JButton ("button1");

    add(button1);

    label1 =  new JLabel ("label1");
    add(label1);

    button2 =  new JButton ("button1");
    add(button2);

    Label2 =  new JLabel ("Label2");
    add(Label2);

    button3 =  new JButton ("button1");
    add(button3);

    Label3 =  new JLabel ("Label3");
    add(Label3);

        }

}

and this is my main class
public class JFrameTester {

/**
 * @param args
 */
public static void main(String[] args) {

    layout Lay = new layout();
     Lay.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     Lay.setVisible(true);

    // JFrame frame = new JFrame("BUY COMPUTER");

    Lay.setSize(800, 600);
        //frame.pack();
   //  frame.setVisible(true);
     Lay.addWindowListener(new MyWindowListener());
 }
}

A: Place the labels and buttons inside a JPanel, and then add that JPanel to your GridLayout. GridLayout automatically resizes components to fit the size of the cell they are placed in and when a JFrame is resized it will adjust the components size as needed. If you place them in JPanels only the JPanel in that cell will be resized, not the components.
EDIT
In addition to that it's Java practice to name all classes with an uppercase letter, your layout should be Layout. However, the name Layout does not accurately convey the purpose of class Layout as your class is not a layout, it's a JFrame. Perhaps LayoutFrame would be a better class name.
And (this is default Java practice) variables should be camelcase, beginning with a lowercase letter and subsequent words having a capital letter e.g. thisIsAVariable. Alternatively you could use underscores which is not normal Java practice, this_is_a_varaible. Given that in Java classes generally start with a capital letter and variables start with a lowercase letter the statement layout Lay = new layout(); looks very strange and a bit confusing at first glance.

redpajama_set_name: RedPajamaStackExchange


text:
Boys' State Track: Boone's Wadsworth to carry torch in field events
Brandon HurleySports Editor
Boone's Colbey Wadsworth has consistently been the Toreadors' top athlete in the field events all year long, and hopes to put a stamp on a successful junior season with a big performance at the state track meet as he qualified for both the Class 3A shot put and discus.
"Considering that I didn't even qualify for either (event) last year, it's a really great feeling," Wadsworth said. "Right now, I'm just trying to help my team. (It's) not really about myself. I want to get in the top-eight. That would help our team place for state and would be a huge accomplishment for my junior year."
Wadsworth swept both events at districts in Gilbert, tossing the shot put 48-8' and won the discus with a throw of 139.' Wadsworth holds the second-longest shot put throw in the Raccoon River Conference with a toss of 49-9.5' and holds the conference's top spot in the discus with a season-best throw of 153'05."
With his first trip to state, Wadsworth plans to stick to the basics and continue with what he's done to prepare all season long.
"(I've been) doing a lot of footwork, a lot of exercising, to stay loose and not get too anxious," he said.
The junior doesn't think the bright lights and big stage in Des Moines will factor in too much.
"I'm going to take deep breaths and worry about the task at hand. I'm not going to focus on what else is going on,"
The Class 3A discus finals get underway at 11:30 a.m. today. Wadsworth is slotted in the first flight. He then will have nearly 24 hours to rest before he's back on the field, as the Class 3A shot put finals begin at 11:30 a.m. Friday, May 20. Wadsworth will throw out of the second flight.


Marketing invades us everywhere--television, radio, internet, clothing, Google, facebook, and newspapers. I find myself telling the children who certain characters are (like Mickey Mouse, or Buzz Lightyear) and then realizing that I'm doing the marketing for these companies, giving these brands their name, desirability, story, and appeal.
Marketing has followed us to our physical mailboxes and email mailboxes, where we are invited to allow companies to contact us through our signing up for a newsletter, or a sale, or a credit card (sometimes we get contacted without our permission, when our name and information is bought and sold among the various corporations out there). I've personally seen this happen after being out of the country for 3 years and then returning, and the mailings have slowly increased as our information has filtered back into the system. We are barraged in our email about offers, jokes, and requests.
It's because of all this that I don't check email constantly, as it is mostly work and notifications and some advertising (I check it once or twice a day; I'm also very careful to unsubscribe from trusted companies whose newsletters I really don't read or need). Email used to be a way to keep in touch with friends and family, but it's now replaced the mailbox as an impersonal method of communication (the same happened to the telephone years ago, especially with robo-calling). It's particularly vital for businesses and work, as it provides a traceable method of communication. Now Twitter is the new space for advertisers, and television shows are increasingly encouraging us to tweet their show or products among our friends, so that they might trend well on Twitter.
Marketing provides a great service when we are told about products and deals we are interested in. Sometimes these are terrific services that we didn't know about, but that make our lives better. For many small software developers, the greatest challenge is the marketing, the getting their products out there and known among people. Advertising also provides cheap and inexpensive products and services, from newspapers to google to facebook. These services are not free, but are supplemented or paid for through the marketing revenues. How does Google make its money? Advertising (they're still not making any money off of Android, despite its success).
All we have left is our texting. That's the one place that's reserved for friends and personal conversations, for the really important and timely questions. So let's keep texting to ourselves and keep it appropriate. Why would I want advertisers to text me? No sale or product could possibly convince me to hand over my privacy and connection to others. Our mailboxes, phones, and email inboxes used to be our own, but they've been corrupted. Let's keep our texting pure.


The Crescent City recently celebrated its largest ever beer festival at the New Orleans City Park Festival Grounds – an unofficial start to the region's Oktoberfest and a chance for brewers both large and small to exchange ideas and innovations while raising money for worthwhile causes.
On Saturday, Sept. 22, the Big Easy hosted its ninth annual NOLA on Tap festival. Founded and sponsored by the Louisiana Society for the Prevention of Cruelty to Animals (SPCA), the event featured beers from powerhouse brands such as Guinness, regional darlings like Urban South and countless local brewers for a thirsty crowd of over 25,000 attendees to sample. The proceeds of the event are used by the Louisiana SPCA for the treatment and care of the animals in their charge.
In addition to the scads of suds from over 100 different vendors, local eateries like the Big Cheezy, Dat Dog and Bratz Y'all were on hand to offer perfect pairings for every pint. The Louisiana SPCA also featured a Barktoberfest tent, where pooches could play while owners imbibed.
Guillory also expanded on the festival's benefits. "It has really given us a chance to improve our community relations, not just by being a sponsor of this event but by allowing us to give back to the community," he said. Guillory explained that Port Orleans Brewing was donating a portion of its proceeds to those battling amyotrophic lateral sclerosis in honor of Steve Gleason, the former New Orleans Saints safety who announced his ALS diagnosis in 2011.
"There's a lot of camaraderie amongst the smaller, local brewing companies. A lot of us participate in NOLA on Tap. We get to exchange ideas, see what's hot right now and see what's on the horizon," said Bergeron.
"Each glass comes with a free donut," laughed Bergeron.
For more information on the festival, visit www.nolaontap.org.


text:
Individuals looking for a vehicle with the practicality of a minivan without any stigma attached to a minivan can consider the 2022 Honda Pilot. This three-row SUV comes with a speedy and fuel-efficient engine with ample cargo and interior space and is packed with popular standard features. Let us find out how the 2022 Honda Pilot compares with the 2022 Toyota Highlander in this article by Steele Honda in St. John's, NL. Continue reading to learn more.
View Our Honda Pilot Inventory
2022 Honda Pilot Touring 8-Passenger
2022 Honda Pilot Black Edition
3.5-litre V6
Base Engine
3.5-Litre, V6
20-inch Aluminum-Alloy Wheels
18-inch Alloy Wheels
Comparing the 2022 Honda Pilot and 2022 Toyota Highlander
Both the 2022 Honda Pilot and the 2022 Toyota Highlander come with a 3.5-liter V6 engine, but the Pilot steals the show with its nine-speed automatic transmission, smoother than the 2022 Highlander's eight-speed. With the 2022 Highlander, drivers can choose between front-wheel or all-wheel drive for every model.
These vehicles come with a host of driver assistance features that reduce the chance of accidents as well as reduce damage in the event of unpreventable crashes. The 2022 Honda Polit offers adaptive cruise control, automatic emergency brakes, and lane-keeping technology in every model. The 2022 Highlander has several, but not all, of the same features as the 2022 Pilot.
Buy the 2022 Honda Pilot Near St. John's, NL
Drivers interested in buying the 2022 Honda Pilot can do so at Steele Honda in St. John's, NL. But before that, stop by the dealership and take the vehicle for a spin. Please feel free to contact the dealership's sales team for any assistance with the purchase. Visit the dealership today!
Interested in a test drive?


Make a Difference in 2017!
Make a New Year's resolution to make a difference in 2017! The Literacy Project of Eagle County needs adult volunteer tutors to work with adults through our one-to-one tutoring program, and teens through our Study Friends program. Our students are seeking help with their reading, writing, math, or English language skills.
The Literacy Project of Eagle County, the community-based tutoring program matching volunteer tutors with community members of all ages, is honoring its Tutor of the Month for November, Pam Brandmeyer.


The next day brings us to the island of Lanai. Purchased by James Dole in 1922 for $1.1 million dollars, Lanai sold 70% of the world's pineapple crop at its peak. The day's activities include snorkeling at Shark Tooth Rock, a tour to the town of Lanai (past former pineapple fields) and a visit to the Lanai Cultural & Heritage Museum. Lanai's picturesque town is filled with charming boutiques, art galleries, and stores selling hand-made jewelry, clothing, and other items. An afternoon hike up the Puu Pehe trail leads us to unforgettable visits over the fabled "Sweetheart Rock." A majestic full moon delights us as we sip cocktails on the upper deck of the Safari Explorer for the perfect end of a perfect day.


Walking very close together so that nobody would see them, they crossed the hall on tiptoe beneath the cloak, then walked down the stone front steps into the grounds. The sun was already sinking behind the Forbidden Forest, gilding the top branches of the trees.
"And you'll be sticking to that story, boy, or there'll be trouble," spat Uncle Vernon.


text:
За германския математик и астроном Мьобиус вижте Аугуст Мьобиус, а за френския кинорежисьор Жан Жиро (кинорежисьор).

Жан Анрѝ Гасто̀н Жиро̀ (), известен с артистичните псевдоними Мьобиус и Жир, е прочут френски художник на комикси.

Той е автор на поредицата за Блубъри. Най-известните филми, в които е участвал като художник, са "Бездната", "Петият елемент" и "Уилоу".

Външни препратки
 Официален сайт

Френски художници на комикси
Френски художници
Илюстратори
Хора от Ил дьо Франс
Починали в Париж
Починали от рак

redpajama_set_name: RedPajamaWikipedia


Community of hope's FREE AnNual Easter Egg hunt!
Join us for Community of Hope's FREE annual Easter Egg Hunt. We're hiding 3000 Eggs for the kids, and have coffee and pastries for the parents. After the hunt, join us inside for to hear the story of Easter story and for each child to receive a take-home gift!
Kids of all ages, and their parents! Family, friends, neighbors, etc. welcome --- we're hiding 3000 eggs, so no there are plenty to go around and no RSVP necessary. The more the merrier!
Saturday, April 13 at 1:00 PM.
*In case of inclement weather, our rain out date is April 20. Check back to this page for weather updates.
For information about COH's Easter Services, click here!


text:
// Copyright 2014 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "volume_reader_javascript_stream.h"

#include <limits>
#include <string>

#include "gtest/gtest.h"
#include "ppapi/cpp/instance_handle.h"
#include "ppapi/utility/threading/simple_thread.h"
#include "ppapi/utility/completion_callback_factory.h"
#include "ppapi_simple/ps_main.h"

// Fake JavaScriptRequestor that responds to
// VolumeReaderJavaScriptStream::Read.
class FakeJavaScriptRequestor : public JavaScriptRequestorInterface {
 public:
  explicit FakeJavaScriptRequestor(pp::InstanceHandle instance_handle)
      : volume_reader_(NULL),
        array_buffer_(50),
        worker_(instance_handle),
        callback_factory_(this),
        force_failure_(false) {
    void* data = array_buffer_.Map();
    memset(data, 1, array_buffer_.ByteLength());
    array_buffer_.Unmap();
  }

  virtual ~FakeJavaScriptRequestor() { worker_.Join(); }

  bool Init() { return worker_.Start(); }

  void RequestFileChunk(const std::string& request_id,
                        int64_t offset,
                        int64_t bytes_to_read) {
    worker_.message_loop().PostWork(callback_factory_.NewCallback(
        &FakeJavaScriptRequestor::RequestFileChunkCallback,
        offset,
        bytes_to_read));
  }

  void RequestPassphrase(const std::string& request_id) {
    worker_.message_loop().PostWork(callback_factory_.NewCallback(
        &FakeJavaScriptRequestor::RequestPassphraseCallback));
  }

  void SetVolumeReader(VolumeReaderJavaScriptStream* volume_reader) {
    volume_reader_ = volume_reader;
  }

  void set_force_failure(bool force_failure) { force_failure_ = force_failure; }

  pp::VarArrayBuffer array_buffer() const { return array_buffer_; }

 private:
  void RequestFileChunkCallback(int32_t /*result*/,
                                int64_t offset,
                                int64_t bytes_to_read) {
    if (offset < 0 || force_failure_) {
      volume_reader_->ReadErrorSignal();
      return;
    }

    int64_t array_buffer_size = array_buffer_.ByteLength();
    if (offset >= array_buffer_size) {
      // Nothing left to read so return empty buffer.
      volume_reader_->SetBufferAndSignal(pp::VarArrayBuffer(0), offset);
    } else {
      // We checked above for negative offsets and offsets > array buffer size
      // so this should be safe.
      int64_t left_size = array_buffer_size - static_cast<int64_t>(offset);
      pp::VarArrayBuffer buffer_to_set(left_size);

      char* data = static_cast<char*>(buffer_to_set.Map());
      char* array_buffer_data = static_cast<char*>(array_buffer_.Map());
      memcpy(data, array_buffer_data + offset, left_size);
      buffer_to_set.Unmap();
      array_buffer_.Unmap();

      volume_reader_->SetBufferAndSignal(buffer_to_set, offset);
    }
  }

  void RequestPassphraseCallback(int32_t /*result*/) {
    if (force_failure_) {
      volume_reader_->PassphraseErrorSignal();
      return;
    }

    // TODO(mtomasz): Improve test coverage for passphrases.
    volume_reader_->SetPassphraseAndSignal("");
  }

  VolumeReaderJavaScriptStream* volume_reader_;
  // Content can be junk. Not important as long as buffer has size > 0. See
  // constructor.
  pp::VarArrayBuffer array_buffer_;

  // Worker to execute requests on a different thread. See
  // VolumeReaderJavaScriptStream method comments.
  pp::SimpleThread worker_;
  pp::CompletionCallbackFactory<FakeJavaScriptRequestor> callback_factory_;

  bool force_failure_;
};

// Class used by TEST_F macro to initialize the environment for testing
// VolumeReaderJavaScriptStream methods.
class VolumeReaderJavaScriptStreamTest : public testing::Test {
 protected:
  VolumeReaderJavaScriptStreamTest()
      : kArchiveSize(std::numeric_limits<int64_t>::max() - 100),
        fake_javascript_requestor(NULL),
        volume_reader(NULL),
        instance_handle(PSGetInstanceId()) {}

  virtual void SetUp() {
    fake_javascript_requestor = new FakeJavaScriptRequestor(instance_handle);
    ASSERT_TRUE(fake_javascript_requestor->Init());

    volume_reader = new VolumeReaderJavaScriptStream(
        kArchiveSize, fake_javascript_requestor);
    fake_javascript_requestor->SetVolumeReader(volume_reader);
    ASSERT_EQ(0, volume_reader->offset());
  }

  virtual void TearDown() {
    delete volume_reader;
    volume_reader = NULL;
    delete fake_javascript_requestor;
    fake_javascript_requestor = NULL;
  }

  // The volume's archive size. Used to test values greater than int32_t.
  const int64_t kArchiveSize;
  FakeJavaScriptRequestor* fake_javascript_requestor;
  VolumeReaderJavaScriptStream* volume_reader;
  pp::InstanceHandle instance_handle;
};

TEST_F(VolumeReaderJavaScriptStreamTest, SmallSkip) {
  // Skip with value smaller than int32_t.
  EXPECT_EQ(1, volume_reader->Skip(1));
  EXPECT_EQ(1, volume_reader->offset());
}

TEST_F(VolumeReaderJavaScriptStreamTest, BigSkip) {
  // Skip with value greater than int32_t but less than archive size.
  int64_t bigBytesToSkipNum = kArchiveSize - 50;  // See kArchiveSize value.
  EXPECT_EQ(bigBytesToSkipNum, volume_reader->Skip(bigBytesToSkipNum));
  EXPECT_EQ(bigBytesToSkipNum, volume_reader->offset());
}

// If read_ahead_length has an invalid length then Skip will return 0.
TEST_F(VolumeReaderJavaScriptStreamTest, ZeroSkip) {
  // Skip with value greater than archive size but less han int64_t max value.
  int64_t veryBigBytesToSkipNum = kArchiveSize + 50;  // See kArchiveSize value.
  EXPECT_EQ(0, volume_reader->Skip(veryBigBytesToSkipNum));
  EXPECT_EQ(0, volume_reader->offset());

  // Can't skip backwards.
  int64_t invalidSkipNum = -1;  // See kArchiveSize value.
  EXPECT_EQ(0, volume_reader->Skip(invalidSkipNum));
  EXPECT_EQ(0, volume_reader->offset());
}

TEST_F(VolumeReaderJavaScriptStreamTest, Seek) {
  // Seek from start.
  EXPECT_EQ(10, volume_reader->Seek(10, SEEK_SET));
  EXPECT_EQ(10, volume_reader->offset());

  // Seek from current with positive value.
  EXPECT_EQ(15, volume_reader->Seek(5, SEEK_CUR));
  EXPECT_EQ(15, volume_reader->offset());

  // Seek from current with negative value.
  EXPECT_EQ(5, volume_reader->Seek(-10, SEEK_CUR));
  EXPECT_EQ(5, volume_reader->offset());

  // Seek from current with value greater than int32_t.
  int64_t positiveSkipValue = kArchiveSize - 50;  // See kArchiveSize value.
  EXPECT_EQ(positiveSkipValue + 5 /* +5 from last Seek call. */,
            volume_reader->Seek(positiveSkipValue, SEEK_CUR));
  EXPECT_EQ(positiveSkipValue + 5, volume_reader->offset());

  // Seek from current with value smaller than int32_t.
  int64_t negativeSkipValue = -positiveSkipValue;
  EXPECT_EQ(5, volume_reader->Seek(negativeSkipValue, SEEK_CUR));
  EXPECT_EQ(5, volume_reader->offset());

  // Seek from start with value greater than int32_t.
  EXPECT_EQ(positiveSkipValue,
            volume_reader->Seek(positiveSkipValue, SEEK_SET));
  EXPECT_EQ(positiveSkipValue, volume_reader->offset());

  // Seek from end. SEEK_END requires negative values.
  EXPECT_EQ(kArchiveSize - 5, volume_reader->Seek(-5, SEEK_END));
  EXPECT_EQ(kArchiveSize - 5, volume_reader->offset());

  // Seek from end with value smaller than int32_t.
  int64_t expectedOffset = kArchiveSize + negativeSkipValue;
  EXPECT_EQ(expectedOffset, volume_reader->Seek(negativeSkipValue, SEEK_END));
  EXPECT_EQ(expectedOffset, volume_reader->offset());

  // Seek from current with 0.
  EXPECT_EQ(expectedOffset, volume_reader->Seek(0, SEEK_CUR));
  EXPECT_EQ(expectedOffset, volume_reader->offset());

  // Seek from start with 0.
  EXPECT_EQ(0, volume_reader->Seek(0, SEEK_SET));
  EXPECT_EQ(0, volume_reader->offset());

  // Seek from end with 0.
  EXPECT_EQ(kArchiveSize, volume_reader->Seek(0, SEEK_END));
  EXPECT_EQ(kArchiveSize, volume_reader->offset());
}

TEST_F(VolumeReaderJavaScriptStreamTest, InvalidSeekNegativeOffsetResult) {
  // Seek that results in negative offsets is invalid.
  EXPECT_EQ(ARCHIVE_FATAL, volume_reader->Seek(-1, SEEK_SET));
}

TEST_F(VolumeReaderJavaScriptStreamTest,
       InvalidSeekOffsetLargerThanArchiveSize) {
  // Seek that results in offsets larger than archive size is invalid.
  EXPECT_EQ(ARCHIVE_FATAL, volume_reader->Seek(1, SEEK_END));
}

TEST_F(VolumeReaderJavaScriptStreamTest, Read) {
  // Valid read with bytes to read = arrayi buffer size.
  int64_t array_buffer_size =
      fake_javascript_requestor->array_buffer().ByteLength();
  const void* buffer = NULL;
  int64_t read_bytes = volume_reader->Read(array_buffer_size, &buffer);
  ASSERT_GE(array_buffer_size, read_bytes);  // Read can return less bytes
                                             // than required.
  ASSERT_GE(read_bytes, 0);

  const void* expected_buffer = fake_javascript_requestor->array_buffer().Map();
  EXPECT_EQ(0, memcmp(buffer, expected_buffer, read_bytes));
  fake_javascript_requestor->array_buffer().Unmap();
}

TEST_F(VolumeReaderJavaScriptStreamTest, BigLengthRead) {
  // Valid read with bytes to read > array buffer size.
  int64_t array_buffer_size =
      fake_javascript_requestor->array_buffer().ByteLength();
  const void* buffer = NULL;
  int64_t read_bytes =
      volume_reader->Read(std::numeric_limits<int64_t>::max(), &buffer);

  // Though the request was for more than array_buffer_size, Read returns
  // maximum array_buffer_size as the buffer is set to array_buffer.
  ASSERT_GE(array_buffer_size, read_bytes);
  ASSERT_GE(read_bytes, 0);

  const void* expected_buffer = fake_javascript_requestor->array_buffer().Map();
  EXPECT_EQ(0, memcmp(buffer, expected_buffer, read_bytes));
  fake_javascript_requestor->array_buffer().Unmap();
}

TEST_F(VolumeReaderJavaScriptStreamTest, SmallReads) {
  // Test multiple reads with bytes to read < array buffer size.

  // First read.
  int64_t array_buffer_size =
      fake_javascript_requestor->array_buffer().ByteLength();
  const void* buffer_1 = NULL;
  int64_t bytes_to_read_1 = array_buffer_size / 4;
  int64_t read_bytes_1 = volume_reader->Read(bytes_to_read_1, &buffer_1);
  ASSERT_GE(bytes_to_read_1, read_bytes_1);
  ASSERT_GE(read_bytes_1, 0);

  const void* expected_buffer_1 =
      fake_javascript_requestor->array_buffer().Map();
  EXPECT_EQ(0, memcmp(buffer_1, expected_buffer_1, read_bytes_1));
  fake_javascript_requestor->array_buffer().Unmap();

  // Second read.
  int64_t bytes_to_read_2 = bytes_to_read_1 * 3;
  const void* buffer_2 = NULL;
  int64_t read_bytes_2 = volume_reader->Read(bytes_to_read_2, &buffer_2);
  ASSERT_GE(bytes_to_read_2, read_bytes_2);
  ASSERT_GE(read_bytes_2, 0);
  ASSERT_GE(array_buffer_size, read_bytes_1 + read_bytes_2);

  const void* expected_buffer_2 =
      static_cast<char*>(fake_javascript_requestor->array_buffer().Map()) +
      read_bytes_1;
  EXPECT_EQ(0, memcmp(buffer_2, expected_buffer_2, read_bytes_2));
  fake_javascript_requestor->array_buffer().Unmap();

  // Third read.
  int64_t bytes_to_read_3 = bytes_to_read_2;
  const void* buffer_3 = NULL;
  int64_t read_bytes_3 = volume_reader->Read(bytes_to_read_3, &buffer_3);
  ASSERT_GE(bytes_to_read_3, read_bytes_3);
  ASSERT_GE(read_bytes_3, 0);
  ASSERT_GE(array_buffer_size, read_bytes_1 + read_bytes_2 + read_bytes_3);

  const void* expected_buffer_3 =
      static_cast<char*>(fake_javascript_requestor->array_buffer().Map()) +
      read_bytes_1 + read_bytes_2;
  EXPECT_EQ(0, memcmp(buffer_3, expected_buffer_3, read_bytes_3));
  fake_javascript_requestor->array_buffer().Unmap();
}

TEST_F(VolumeReaderJavaScriptStreamTest, EndOfArchiveRead) {
  // Read at the end of archive.
  volume_reader->Seek(0, SEEK_END);
  const void* buffer = NULL;
  EXPECT_EQ(0, volume_reader->Read(1, &buffer));
}

TEST_F(VolumeReaderJavaScriptStreamTest, InvalidRead) {
  // Force read ahead with Seek after setting force failure to true. This is
  // necessary because the constructor read ahead will be successful if it
  // finishes before we do set_force_failure.
  fake_javascript_requestor->set_force_failure(true);
  volume_reader->Seek(0, SEEK_SET);
  int64_t bytes_to_read =
      fake_javascript_requestor->array_buffer().ByteLength();
  const void* buffer = NULL;
  EXPECT_EQ(ARCHIVE_FATAL, volume_reader->Read(bytes_to_read, &buffer));
}

redpajama_set_name: RedPajamaGithub


text:
Zoonomia, Vol. I - Or, the Laws of Organic Life
Erasmus Darwin - nefing
! " # $ " % ! & ! ! ' ( & ( & ) ' * ' )$ +, +--, . /0,1-12 & ' 3 ! ' 4(%55,6%0 777 4 )* (8 9 4 *(: 3 ; ) (& 777 ! ! ) $ * 4 = ! ! ( ! ! ! " " # " $ !% & " ' ( ! " ) * $ ! $ ! ! ! +, - . / ! 0/! /! 1 ! 1 1 % !!1 $ / ! ) % 1 $/ 2 / $ ) ! % % ! 1 . 3 4! 5/ ! / 0! 1 ! / * 1 / % ! 1 )) . '! 5 1 / $ % 1 $ 0 / / 0/! # 6 7 7 ' ' #2' 89 :; 0 / $ % 1 %3 / /! 9 * 3 : :; / ) 1 ) 1C 5/ $ 08%! / 0 > $ 3 )! 1 E 1 3!
Published by nefing
The Project Gutenberg EBook of Zoonomia, Vol. I, by Erasmus Darwin
This eBook is for the use of anyone anywhere at no cost and with almost no restrictions whatsoever. You may copy it, give it away or re-use it under the terms of the Project Gutenberg License included with this eBook or online at www.gutenberg.net
Title: Zoonomia, Vol. I Or, the Laws of Organic Life
Author: Erasmus Darwin
Release Date: April 25, 2005 [EBook #15707]
Character set encoding: ISO-8859-1
*** START OF THIS PROJECT GUTENBERG EBOOK ZOONOMIA, VOL. I ***
Produced by Greg Alethoup, Robert Shimmin, Keith Edkins and the Online Distributed Proofreading Team.
ZOONOMIA;
ORGANIC LIFE.
By ERASMUS DARWIN, M.D. F.R.S.
AUTHOR OF THE BOTANIC GARDEN.
Principiò cœlum, ac terras, camposque liquentes, Lucentemque globum lunæ, titaniaque astra, Spiritus intùs alit, totamque infusa per artus
Mens agitat molem, et magno se corpore miscet.—VIRG. Æn. vi.
Earth, on whose lap a thousand nations tread, And Ocean, brooding his prolific bed, Night's changeful orb, blue pole, and silvery zones, Where other worlds encircle other suns, One Mind inhabits, one diffusive Soul Wields the large limbs, and mingles with the whole.
THE SECOND EDITION, CORRECTED.
LONDON: PRINTED FOR. J. JOHNSON, IN ST. PAUL'S CHURCH-YARD. 1796.
Entered at Stationers' Hall.
DEDICATION.
To the candid and ingenious Members of the College of Physicians, of the Royal Philosophical Society, of the Two Universities, and to all those, who study the Operations of the Mind as a Science, or who practice Medicine as a Profession, the subsequent Work is, with great respect, inscribed by the Author,
DERBY, May 1, 1794.
Preface. SECT.I.Of Motion. II.Explanations and Definitions. III.The Motions of the Retina demonstrated by Experiments. IV.Laws of Animal Causation. V.Of the four Faculties or Motions of the Sensorium. VI.Of the four Classes of Fibrous Motions. VII.Of Irritative Motions. VIII.Of Sensitive Motions. IX.Of Voluntary Motions. X.Of Associate Motions. XI.Additional Observations on the Sensorial Powers. XII.Of Stimulus, Sensorial Exertion, and Fibrous Contraction. XIII.Of Vegetable Animation. XIV.Of the Production of Ideas. XV.Of the Classes of Ideas. XVI.Of Instinct.
XVII.The Catenation of Animal Motions. XVIII.Of Sleep. XIX.Of Reverie. XX.Of Vertigo. XXI.Of Drunkenness. XXII.Of Propensity to Motion. Repetition. Imitation. XXIII.Of the Circulatory System. Of the Secretion of Saliva, and of Tears. And of the Lacrymal XXIV. Sack. XXV.Of the Stomach and Intestines. XXVI.Of the Capillary Glands, and of the Membranes. XXVII.Of Hemorrhages. XXVIII.The Paralysis of the Lacteals. XXIX.The Retrograde Motions of the Absorbent Vessels. XXX.The Paralysis of the Liver. XXXI.Of Temperaments. XXXII.Diseases of Irritation. XXXIII. ——of Sensation. XXXIV. ——of Volition. XXXV. ——of Relation. XXXVI.The Periods of Diseases. XXXVII.Of Digestion, Secretion, Nutrition. XXXVIII.Of the Oxygenation of the Blood in the Lungs and Placenta. XXXIX.Of Generation. XL.Of Ocular Spectra.
ERASMUS DARWIN,
ON HIS WORK INTITLED
ZOONOMIA,
By DEWHURST BILSBORROW.
HAIL TO THE BARD! who sung, from Chaos hurl'd How suns and planets form'd the whirling world; How sphere on sphere Earth's hidden strata bend, And caves of rock her central fires defend; Where gems new-born their twinkling eyes unfold, 5 And young ores shoot in arborescent gold. How the fair Flower, by Zephyr woo'd, unfurls Its panting leaves, and waves its azure curls; Or spreads in gay undress its lucid form To meet the sun, and shuts it to the storm; 10 While in green veins impassion'd eddies move, And Beauty kindles into life and love. How the first embryon-fibre, sphere, or cube,
Lives in new forms,—a line,—a ring,—a tube; Closed in the womb with limbs unfinish'd laves, 15 Sips with rude mouth the salutary waves; Seeks round its cell the sanguine streams, that pass, And drinks with crimson gills the vital gas; Weaves with soft threads the blue meandering vein, The heart's red concave, and the silver brain; 20 Leads the long nerve, expands the impatient sense, And clothes in silken skin the nascent Ens. Erewhile, emerging from its liquid bed, It lifts in gelid air its nodding head; The lights first dawn with trembling eyelid hails, 25 With lungs untaught arrests the balmy gales; Tries its new tongue in tones unknown, and hears The strange vibrations with unpractised ears; Seeks with spread hands the bosom's velvet orbs. With closing lips the milky fount absorbs; 30 And, as compress'd the dulcet streams distil, Drinks warmth and fragrance from the living rill;— Eyes with mute rapture every waving line, Prints with adoring kiss the Paphian shrine, And learns erelong, the perfect form confess'd, 35 Ideal Beauty from its mother's breast. Now in strong lines, with bolder tints design'd, You sketch ideas, and portray the mind; Teach how fine atoms of impinging light To ceaseless change the visual sense excite; 40 While the bright lens collects the rays, that swerve, And bends their focus on the moving nerve. How thoughts to thoughts are link'd with viewless chains, Tribes leading tribes, and trains pursuing trains; With shadowy trident how Volition guides, 45 Surge after surge, his intellectual tides; Or, Queen of Sleep, Imagination roves With frantic Sorrows, or delirious Loves. Go on, O FRIEND! explore with eagle-eye; Where wrapp'd in night retiring Causes lie: 50 Trace their slight bands, their secret haunts betray, And give new wonders to the beam of day; Till, link by link with step aspiring trod, You climb from NATUREto the throne of GOD. —So saw the Patriarch with admiring eyes 55 From earth to heaven a golden ladder rise; Involv'd in clouds the mystic scale ascends, And brutes and angels crowd the distant ends.
TRIN. COL. CAMBRIDGE,Jan.1, 1794.
REFERENCES TO THE WORK.
Botanic Garden.Part I.
Line 1. Canto I. l. 105. —— 3. —— IV. l. 402. —— 4. —— I. l. 140. —— 5. —— III. l. 401. —— 8. —— IV. l. 452.
—— 9. —— I. l. 14.
Zoonomia.
—— 12. Sect.XIII. —— 13. ——XXXIX. 4. 1. —— 18. ——XVI. 2. andXXXVIII. —— 26. ——XVI. 4. —— 30. ——XVI. 4. —— 36. ——XVI. 6. —— 38. ——III. andVII. —— 43. ——X. —— 44. ——XVIII. 17. —— 45. ——XVII. 3. 7. —— 47. ——XVIII. 8. —— 50. ——XXXIX. 4. 8. —— 51. ——XXXIXthe Motto. —— 54. ——XXXIX. 8.
The purport of the following pages is an endeavour to reduce the facts belonging to ANIMAL LIFEclasses, orders, genera, and species; and, by into comparing them with each other, to unravel the theory of diseases. It happened, perhaps unfortunately for the inquirers into the knowledge of diseases, that other sciences had received improvement previous to their own; whence, instead of comparing the properties belonging to animated nature with each other, they, idly ingenious, busied themselves in attempting to explain the laws of life by those of mechanism and chemistry; they considered the body as an hydraulic machine, and the fluids as passing through a series of chemical changes, forgetting that animation was its essential characteristic.
The great CREATORof all things has infinitely diversified the works of his hands, but has at the same time stamped a certain similitude on the features of nature, that demonstrates to us, thatthe whole is one family of one parent. On this similitude is founded all rational analogy; which, so long as it is concerned in comparing the essential properties of bodies, leads us to many and important discoveries; but when with licentious activity it links together objects, otherwise discordant, by some fanciful similitude; it may indeed collect ornaments for wit and poetry, but philosophy and truth recoil from its combinations.
The want of a theory, deduced from such strict analogy, to conduct the practice of medicine is lamented by its professors; for, as a great number of unconnected facts are difficult to be acquired, and to be reasoned from, the art of medicine is in many instances less efficacious under the direction of its wisest practitioners; and by that busy crowd, who either boldly wade in darkness, or are led into endless error by the glare of false theory, it is daily practised to the destruction of thousands; add to this the unceasing injury which accrues to the public by the perpetual advertisements of pretended nostrums; the minds of the indolent become superstitiously fearful of diseases, which they do not labour under; and thus become the daily prey of some crafty empyric.
A theory founded upon nature, that should bind together the scattered facts of medical knowledge, and converge into one point of view the laws of organic life, would thus on many accounts contribute to the interest of society. It would capacitate men of moderate abilities to practise the art of healing with real
advantage to the public; it would enable every one of literary acquirements to distinguish the genuine disciples of medicine from those of boastful effrontery, or of wily address; and would teach mankind in some important situations the knowledge of themselves.
There are some modern practitioners, who declaim against medical theory in general, not considering that to think is to theorize; and that no one can direct a method of cure to a person labouring under disease without thinking, that is, without theorizing; and happy therefore is the patient, whose physician possesses the best theory.
The words idea, perception, sensation, recollection, suggestion, and association, are each of them used in this treatise in a more limited sense than in the writers of metaphysic. The author was in doubt, whether he should rather have substituted new words instead of them; but was at length of opinion, that new definitions of words already in use would be less burthensome to the memory of the reader.
A great part of this work has lain by the writer above twenty years, as some of his friends can testify: he had hoped by frequent revision to have made it more worthy the acceptance of the public; this however his other perpetual occupations have in part prevented, and may continue to prevent, as long as he may be capable of revising it; he therefore begs of the candid reader to accept of it in its present state, and to excuse any inaccuracies of expression, or of conclusion, into which the intricacy of his subject, the general imperfection of language, or the frailty he has in common with other men, may have betrayed him; and from which he has not the vanity to believe this treatise to be exempt.
SECT. I.
OF MOTION.
The whole of nature may be supposed to consist of two essences or substances; one of which may be termed spirit, and the other matter. The former of these possesses the power to commence or produce motion, and the latter to receive and communicate it. So that motion, considered as a cause, immediately precedes every effect; and, considered as an effect, it immediately succeeds every cause.
TheMOTIONS OF MATTERmay be divided into two kinds, primary and secondary. The secondary motions are those, which are given to or received from other matter in motion. Their laws have been successfully investigated by philosophers in their treatises on mechanic powers. These motions are distinguished by this circumstance, that the velocity multiplied into the quantity of matter of the body acted upon is equal to the velocity multiplied into the quantity of matter of the acting body.
The primary motions of matter may be divided into three classes, those belonging to gravitation, to chemistry, and to life; and each class has its peculiar laws. Though these three classes include the motions of solid, liquid, and aerial bodies; there is nevertheless a fourth division of motions; I mean those of the supposed ethereal fluids of magnetism, electricity, heat, and light; whose properties are not so well investigated as to be classed with sufficient accuracy.
1st.The gravitating motions include the annual and diurnal rotation of the earth and planets, the flux and reflux of the ocean, the descent of heavy bodies, and other phænomena of gravitation. The unparalleled sagacity of the great NEWTONhas deduced the laws of this class of motions from the simple principle o f the general attraction of matter. These motions are distinguished by their tendency to or from the centers of the sun or planets.
2d. The chemical class of motions includes all the various appearances of chemistry. Many of the facts, which belong to these branches of science, are nicely ascertained, and elegantly classed; but their laws have not yet been developed from such simple principles as those above-mentioned; though it is probable, that they depend on the specific attractions belonging to the particles of bodies, or to the difference of the quantity of attraction belonging to the sides and angles of those particles. The chemical motions are distinguished by their being generally attended with an evident decomposition or new combination of the active materials.
3d.The third class includes all the motions of the animal and vegetable world; as well those of the vessels, which circulate their juices, and of the muscles, which perform their locomotion, as those of the organs of sense, which constitute their ideas.
This last class of motion is the subject of the following pages; which, though conscious of their many imperfections, I hope may give some pleasure to the patient reader, and contribute something to the knowledge and to the cure of diseases.
SECT. II.
EXPLANATIONS AND DEFINITIONS.
I.Outline of the animal economy.—II.1.Of the sensorium.2.Of the brain and nervous medulla.3.A nerve.4.A muscular fibre.5.The immediate organs of sense.6.of sense.The external organs 7.An idea or sensual motion.8.Perception.9.Sensation.10.Recollection and suggestion.11.Habit, causation, association, catenation.12. Reflex ideas.13.Stimulus defined.
As some explanations and definitions will be necessary in the prosecution of the work, the reader is troubled with them in this place, and is intreated to keep them in his mind as he proceeds, and to take them for granted, till an apt opportunity occurs to evince their truth; to which I shall premise a very short outline of the animal economy.
I.—1. The nervous system has its origin from the brain, and is distributed to every part of the body. Those nerves, which serve the senses, principally arise from that part of the brain, which is lodged in the head; and those, which serve the purposes of muscular motion, principally arise from that part of the brain, which is lodged in the neck and back, and which is erroneously called the spinal marrow. The ultimate fibrils of these nerves terminate in the immediate organs of sense and muscular fibres, and if a ligature be put on any part of their passage from the head or spine, all motion and perception cease in the parts beneath the ligature.
2. The longitudinal muscular fibres compose the locomotive muscles, whose contractions move the bones of the limbs and trunk, to which their extremities are attached. The annular or spiral muscular fibres compose the vascular muscles, which constitute the intestinal canal, the arteries, veins, glands, and absorbent vessels.
3. The immediate organs of sense, as the retina of the eye, probably consist of moving fibrils, with a power of contraction similar to that of the larger muscles above described.
4. The cellular membrane consists of cells, which resemble those of a sponge, communicating with each other, and connecting together all the other parts of the body.
5. The arterial system consists of the aortal and the pulmonary artery, which are attended through their whole course with their correspondent veins. The pulmonary artery receives the blood from the right chamber of the heart, and carries it to the minute extensive ramifications of the lungs, where it is exposed to the action of the air on a surface equal to that of the whole external skin, through the thin moist coats of those vessels, which are spread on the air-cells, which constitute the minute terminal ramifications of the wind-pipe. Here the blood changes its colour from a dark red to a bright scarlet. It is then collected by the branches of the pulmonary vein, and conveyed to the left chamber of the heart.
6. The aorta is another large artery, which receives the blood from the left chamber of the heart, after it has been thus aerated in the lungs, and conveys it by ascending and descending branches to every other part of the system; the extremities of this artery terminate either in glands, as the salivary glands, lacrymal glands, &c. or in capillary vessels, which are probably less involuted glands; in these some fluid, as saliva, tears, perspiration, are separated from the blood; and the remainder of the blood is absorbed or drank up by branches of veins correspondent to the branches of the artery; which are furnished with valves to prevent its return; and is thus carried back, after having again changed its colour to a dark red, to the right chamber of the heart. The circulation of the blood in the liver differs from this general system; for the veins which drink up the refluent blood from those arteries, which are spread on the bowels and mesentery, unite into a trunk in the liver, and form a kind of artery, which is branched into the whole substance of the liver, and is called the vena portarum; and from which the bile is separated by the numerous hepatic glands, which constitute that viscus.
7. The glands may be divided into three systems, the convoluted glands, such as those above described, which separate bile, tears, saliva, &c. Secondly, the glands without convolution, as the capillary vessels, which unite the terminations of the arteries and veins; and separate both the mucus, which lubricates the cellular membrane, and the perspirable matter, which preserves the skin moist and flexible. And thirdly, the whole absorbent system, consisting of the lacteals, which open their mouths into the stomach and intestines, and of the lymphatics, which open their mouths on the external surface of the body, and on the internal linings of all the cells of the cellular membrane, and other cavities of the body.
These lacteal and lymphatic vessels are furnished with numerous valves to prevent the return of the fluids, which they absorb, and terminate in glands, called lymphatic glands, and may hence be considered as long necks or mouths belonging to these glands. To these they convey the chyle and mucus, with a part of the perspirable matter, and atmospheric moisture; all which, after having passed through these glands, and having suffered some change in them, are carried forward into the blood, and supply perpetual nourishment to the system, or replace its hourly waste.
8. The stomach and intestinal canal have a constant vermicular motion, which carries forwards their contents, after the lacteals have drank up the chyle from them; and which is excited into action by the stimulus of the aliment we swallow, but which becomes occasionally inverted or retrograde, as in vomiting, and in the iliac passion.
II. 1. The wordsensoriumin the following pages is designed to express not only the medullary part of the brain, spinal marrow, nerves, organs of sense, and of the muscles; but also at the same time that living principle, or spirit of animation, which resides throughout the body, without being cognizable to our senses, except by its effects. The changes which occasionally take place in the sensorium, as during the exertions of volition, or the sensations of pleasure or pain, are termedsensorial motions.
2. The similarity of the texture of the brain to that of the pancreas, and some other glands of the body, has induced the inquirers into this subject to believe, that a fluid, perhaps much more subtile than the electric aura, is separated from the blood by that organ for the purposes of motion and sensation. When we recollect, that the electric fluid itself is actually accumulated and given out voluntarily by the torpedo and the gymnotus electricus, that an electric shock will frequently stimulate into motion a paralytic limb, and lastly that it needs no perceptible tubes to convey it, this opinion seems not without probability; and the singular figure of the brain and nervous system seems well adapted to distribute it over every part of the body.
For the medullary substance of the brain not only occupies the cavities of the head and spine, but passes along the innumerable ramifications of the nerves to the various muscles and organs of sense. In these it lays aside its coverings, and is intermixed with the slender fibres, which constitute those muscles and organs of sense. Thus all these distant ramifications of the sensorium are united at one of their extremities, that is, in the head and spine; and thus these central parts of the sensorium constitute a communication between all the organs of sense and muscles.
3. Anervemedullary substance of the brain from the is a continuation of the head or spine towards the other parts of the body, wrapped in its proper membrane.
4. Themuscular fibres are moving organs intermixed with that medullary substance, which is continued along the nerves, as mentioned above. They are indued with the power of contraction, and are again elongated either by antagonist muscles, by circulating fluids, or by elastic ligaments. So the muscles on one side of the forearm bend the fingers by means of their tendons, and those on the other side of the fore-arm extend them again. The arteries are distended by the circulating blood; and in the necks of quadrupeds there is a strong elastic ligament, which assists the muscles, which elevate the head, to keep it in its horizontal position, and to raise it after it has been depressed.
5. Theimmediate organs of sense consist in like manner of moving fibres enveloped in the medullary substance above mentioned; and are erroneously supposed to be simply an expansion of the nervous medulla, as the retina of the eye, and the rete mucosum of the skin, which are the immediate organs of vision, and of touch. Hence when we speak of the contractions of the fibrous parts of the body, we shall mean both the contractions of the muscles, and those of the immediate organs of sense. Thesefibrous motions are thus distinguished from thesensorial motionsabove mentioned.
6. Theexternal organsthe coverings of the immediate organs ofsense are of sense, and are mechanically adapted for the reception or transmission of peculiar bodies, or of their qualities, as the cornea and humours of the eye, the tympanum of the ear, the cuticle of the finders and tongue.
7. The wordideahas various meanings in the writers of metaphysic: it is here used simply for those notions of external things, which our organs of sense bring us acquainted with originally; and is defined a contraction, or motion, or configuration, of the fibres, which constitute the immediate organ of sense; which will be explained at large in another part of the work. Synonymous with the word idea, we shall sometimes use the wordssensual motion in contradistinction tomuscular motion.
8. The wordperception includes action of the organ of sense inboth the consequence of the impact of external objects, and our attention to that action; that is, it expresses both the motion of the organ of sense, or idea, and the pain or pleasure that succeeds or accompanies it.
9. The pleasure or pain which necessarily accompanies all those perceptions or ideas which we attend to, either gradually subsides, or is succeeded by other fibrous motions. In the latter case it is termedsensation, as explained in Sect. V. 2, andVI. 2.—The reader is intreated to keep this in his mind, that through all this treatise the word sensation is used to express pleasure or pain only in its active state, by whatever means it is introduced into the system, without any reference to the stimulation of external objects.
10. The vulgar use of the wordmemoryis too unlimited for our purpose: those ideas which we voluntarily recall are here termed ideas ofrecollection, as when we will to repeat the alphabet backwards. And those ideas which are suggested to us by preceding ideas are here termed ideas ofsuggestion, as whilst we repeat the alphabet in the usual order; when by habits previously acquired B is suggested by A, and C by B, without any effort of deliberation.
11. The wordassociationproperly signifies a society or convention of things in some respects similar to each other. We never say in common language, that the effect is associated with the cause, though they necessarily accompany or succeed each other. Thus the contractions of our muscles and organs of sense may be said to be associated together, but cannot with propriety be said to be associated with irritations, or with volition, or with sensation; because they are caused by them, as mentioned in Sect.IV. When fibrous contractions succeed other fibrous contractions, the connection is termedassociation; when fibrous contractions succeed sensorial motions, the connection is termedcausation; when fibrous and sensorial motions reciprocally introduce each other in progressive trains or tribes, it is termedcatenationof animal motions. All these connections are said to be produced byhabit; that is, by frequent repetition.
12. It may be proper to observe, that by the unavoidable idiom of our language the ideas of perception, of recollection, or of imagination, in the plural number signify the ideas belonging to perception, to recollection, or to imagination; whilst the idea of perception, of recollection, or of imagination, in the singular number is used for what is termed "a reflex idea of any of those operations of the sensorium."
13. By the wordstimulusis not only meant the application of external bodies to our organs of sense and muscular fibres, which excites into action the sensorial power termed irritation; but also pleasure or pain, when they excite into action the sensorial power termed sensation; and desire or aversion, when they excite into action the power of volition; and lastly, the fibrous contractions which precede association; as is further explained in Sect.XII. 2. 1.
SECT. III.
THE MOTIONS OF THE RETINA DEMONSTRATED BY EXPERIMENTS.
I.Of animal motions and of ideas.II.The fibrous structure of the retina.III.The activity of the retina in vision.1.Rays of light have no momentum.2.Objects long viewed become fainter.3.Spectra of black objects become luminous.4.Varying spectra from gyration.5. From long inspection of various colours.IV.organs ofMotions of the sense constitute ideas.1.Light from pressing the eye-ball, and sound from the pulsation of the carotid artery.2.Ideas in sleep mistaken for perceptions.3.Ideas of imagination produce pain and sickness like sensations.4.When the organ of sense is destroyed, the ideas belonging to that sense perish.V.Analogy between muscular motions and sensual motions, or ideas.1.They are both originally excited by irritations.2.together in the same manner.And associated 3.in nearly the same times.Both act 4.alike strengthened orA re fatigued by exercise.5.Are alike painful from inflammation.6.Are alike benumbed by compression.7.Are alike liable to paralysis.8.To convulsion.9.To the influence of old age.—VI.Objections answered. 1.Why we cannot invent new ideas.2.If ideas resemble external objects.3.limb.Of the imagined sensation in an amputated 4. Abstract ideas.—VII.What are ideas, if they are not animal motions?
Before the great variety of animal motions can be duly arranged into natural classes and orders, it is necessary to smooth the way to this yet unconquered field of science, by removing some obstacles which thwart our passage. I. To demonstrate that the retina and other immediate organs of sense possess a power of motion, and that these motions constitute our ideas, according to the fifth and seventh of the preceding assertions, claims our first attention.
Animal motions are distinguished from the communicated motions, mentioned in the first section, as they have no mechanical proportion to their cause; for the goad of a spur on the skin of a horse shall induce him to move a load of hay. They differ from the gravitating motions there mentioned as they are exerted with equal facility in all directions, and they differ from the chemical class of motions, because no apparent decompositions or new combinations are produced in the moving materials.
Hence, when we say animal motion is excited by irritation, we do not mean that the motion bears any proportion to the mechanical impulse of the stimulus; nor that it is affected by the general gravitation of the two bodies; nor by their chemical properties, but solely that certain animal fibres are excited into action by something external to the moving organ.
In this sense the stimulus of the blood produces the contractions of the heart; and the substances we take into our stomach and bowels stimulate them to perform their necessary functions. The rays of light excite the retina into animal motion by their stimulus; at the same time that those rays of light themselves are physically converged to a focus by the inactive humours of the eye. The vibrations of the air stimulate the auditory nerve into animal action; while it is probable that the tympanum of the ear at the same time undergoes a mechanical vibration.
To render this circumstance more easy to be comprehended,bemotion may defined to be a variation of figure; for the whole universe may be considered as one thing possessing a certain figure; the motions of any of its parts are a variation of this figure of the whole: this definition of motion will be further explained in SectionXIV. 2. 2. on the production of ideas.
Now the motions of an organ of sense are a succession of configurations of that organ; these configurations succeed each other quicker or slower; and whatever configuration of this organ of sense, that is, whatever portion of the motion of it is, or has usually been, attended to, constitutes an idea. Hence the configuration is not to be considered as an effect of the motion of the organ, but
Guy Fawkes - or A Complete History Of The Gunpowder Treason, A.D. 1605
History of Human Society
Account of a Tour in Normandy, Volume 2
Preliminary Specifications: Programmed Data Processor Model Three (PDP-3) - October, 1960
Birch Bark Legends of Niagara