[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #62538] [octave forge] (arduino) playTone func
From: |
Koichi Hamada |
Subject: |
[Octave-bug-tracker] [bug #62538] [octave forge] (arduino) playTone function does not play the correct frequency |
Date: |
Sat, 28 May 2022 21:22:26 -0400 (EDT) |
URL:
<https://savannah.gnu.org/bugs/?62538>
Summary: [octave forge] (arduino) playTone function does not
play the correct frequency
Project: GNU Octave
Submitted by: hamadak2000
Submitted on: Sun 29 May 2022 01:22:24 AM UTC
Category: Octave Forge Package
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Koichi Hamada
Originator Email:
Open/Closed: Open
Release: 6.4.0
Discussion Lock: Any
Operating System: Any
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Sun 29 May 2022 01:22:24 AM UTC By: Koichi Hamada <hamadak2000>
I found a computational bug in "playTone.m".
The bit-shift operation is incorrect at Line 64 in file "playTone.m".
63: freq = uint16(freq);
64: freqh = bitand(freq/256, hex2dec('FF'));
The bitshift() function shold be used for bit-shift operation.
This is because division over uint16 types does not return the value we
expect.
For example, Octave returns "2" as a result of "uint16(400)/256".
So the code "freq/256" at Line 64 should be replace by "bitshift(freq, -8)".
Line 68 needs the same modification.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62538>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #62538] [octave forge] (arduino) playTone function does not play the correct frequency,
Koichi Hamada <=